我的机构目前从2009年初开始运行Google Apps for Education.我负责创建,删除,修改学生电子邮件帐户等.我已将所有现有的C#应用程序从GData转换为新的Admin SDK - 生活很美好.
上周,其中一个部门向大约800名学生发送了一封包含错误的电子邮件.我被问到是否可以创建一个能够删除800个学生收件箱的电子邮件的快速应用程序.
使用我的"超级管理员"域帐户,我可以使用Gmail API创建一个应用程序,以进入我的收件箱并选择符合特定条件的特定电子邮件; 示例:from:xxxx@domain.edu AND is:unread AND subject:test 我能够返回消息ID的集合,然后我可以从收件箱中删除它们 - 太棒了!
由于我能够在我的收件箱中执行此操作,因此我认为我会进行另一项测试并插入其中一个800电子邮件地址并获得相同的结果.不幸的是我收到此错误消息:
错误:Google.Apis.Requests.RequestError拒绝委托xxxxx@domain.edu [403]错误[消息[委托被拒绝xxxxx@domain.edu]位置[ - ]原因[禁止]域[全局]]
我确实阅读了有关帐户委派的内容,但这需要从我的"超级管理员"帐户发送请求,并且学生接受该请求.
可能是域名的"超级管理员"在任何收件箱中没有这些权限,除了他们自己的?我试过阅读帖子和谷歌的文档,但我似乎无法找到关于这个主题的答案.
在此桌面应用程序的开发人员控制台中启用了Gmail API.
我正在使用的服务帐户已获得授权,并且在C#应用程序中使用的是正确的范围:
Scopes = new[] {
"https://mail.google.com",
GmailService.Scope.GmailCompose,
GmailService.Scope.GmailInsert,
GmailService.Scope.GmailLabels,
GmailService.Scope.GmailModify,
GmailService.Scope.GmailReadonly,
GmailService.Scope.MailGoogleCom,
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"},
Run Code Online (Sandbox Code Playgroud)
我的C#代码:
List<Google.Apis.Gmail.v1.Data.Message> result = new List<Google.Apis.Gmail.v1.Data.Message>();
UsersResource.MessagesResource.ListRequest request = GoogleToken.GoogleService().Users.Messages.List("xxxxx@domain.edu");
request.Q = " from:xxxx@domain.edu AND is:unread AND subject:test ";
do
{
try
{
ListMessagesResponse response = request.Execute();
result.AddRange(response.Messages);
request.PageToken = response.NextPageToken;
}
catch (Exception eX)
{
Debug.WriteLine("Error: " …Run Code Online (Sandbox Code Playgroud) 我有以下硬编码的json,
var dataLocality = [
{ "label": "Arwen" },
{ "label": "Bilbo Baggins" },
{ "label": "Boromir" },
{ "label": "Frodo Baggins" },
{ "label": "Peregrin Pippin Took" },
{ "label": "Samwise Gamgee" }
];
Run Code Online (Sandbox Code Playgroud)
我使用以下脚本填充自动填充文本框,
$(function () {
$("#locality").autocomplete(
{
source: dataLocality
})
});
Run Code Online (Sandbox Code Playgroud)
我现在有一个文本文件,通过我的应用程序名为dataLocality.text动态更新,我可以使用此代码在警报框中加载和查看,
function codeAddress() {
jQuery.get('http://localhost/project/jSonDocs/dataWhat.txt', function (data) {
var dataLocality = data;
alert(dataLocality);
});
}
window.onload = codeAddress;
Run Code Online (Sandbox Code Playgroud)
但我似乎无法制定出如何从获取数据var dataLocality到source: dataLocality
我的文档doc中的数据如下所示,
[
{ "label": "Arwen" },
{ "label": "Bilbo Baggins" }, …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用以下方法更新事件:
PUT https://www.googleapis.com/calendar/v3/calendars/primary/events/q4es0o2o70naq8idj1dj6q4354
{
"reminders" {"useDefault":true},
"summary":"updatedsummary",
"description":"updated desc"
}
Run Code Online (Sandbox Code Playgroud)
但得到回应:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Missing end time."
}
],
"code": 400,
"message": "Missing end time."
}
}
Run Code Online (Sandbox Code Playgroud)
如果我只需要更新摘要或其他字段,为什么还需要结束时间?
我正在使用Rails REST后端编写我的第一个Backbone.js应用程序,令我困惑的一件事是模型之间的关系.
这个应用程序,我写会Ticket和Client为榜样.我也设置了两个Tickets和Clients集合.
事实证明我有几千个客户,我不想将它们加载到内存中,相反,当机票引用时,我想懒洋洋地加载客户.
我尝试过一种非常天真的方法,显然不起作用,因为Model#fetch()方法是异步的.
这是我目前为止的Ticket模型(在CoffeeScript中):
class Deputy.Models.Ticket extends Backbone.Model
initialize: ->
@fetchClient()
fetchClient: ->
@client = new Deputy.Models.Client()
@client.set id: @get('userid')
@client.fetch()
clientName: ->
first = @client.get('firstname')
last = @client.get('lastname')
"#{first} #{last}"
Run Code Online (Sandbox Code Playgroud)
可以想象,该clientName()函数始终返回"undefined undefined",因为在调用时fetch没有返回.
处理这种数据关系的正确方法是什么?请注意,我不介意你退后一步,说我使用了错误的方法并建议我做一些事情.
任何指针,文章或任何其他内容将不胜感激.
我只是尝试使用todo示例将backbone.js用于我的项目.在我的app.js文件中,我尝试实例化我的视图/模型/集合等但我尝试得到错误消息:应用程序未在TodoList中定义.
HTML:
<head>
<script type="text/javascript" src="js/json2.js"></script>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/underscore-min.js"></script>
<script type="text/javascript" src="js/backbone-min.js"></script>
<script type="text/javascript" src="js/backbone-localstorage.js"></script>
<script type="text/javascript" src="js/models/models.js"></script>
<script type="text/javascript" src="js/collections/collections.js"></script>
<script type="text/javascript" src="js/views/views.js"></script>
<script type="text/javascript" src="js/views/app.js"></script>
<script type="text/javascript" src="js/app.js"></script>
Run Code Online (Sandbox Code Playgroud)
app.js(我的应用程序的root):
var app = {
models:{},
collections:{},
views:{}
};
jQuery(function($) {
var Todos = new app.collections.TodoList;
var test = new Todo;
var test2 = new TodoView;
var appView = new AppView({});
});
Run Code Online (Sandbox Code Playgroud)
collections.js:
app.collections.TodoList = Backbone.Collection.extend({
model: Todo,
localStorage: new Store("todos"),
done: function() {
return this.filter(function(todo) { …Run Code Online (Sandbox Code Playgroud) 我正在开发一个使用XCode 4.2以iOS4为目标的应用程序.从来没有做过,这是我开发iPhone应用程序的第一个月.
我做了一些研究,并且进行了ASIHTTPRequest - 它没有被维护,甚至开发人员建议使用其他东西:http://allseeing-i.com/%5Brequest_release%5D ;
从那个列表中,我想为什么不使用NSUrlConnection,因为它是在XCode中构建的.我知道RESTKit在那里看起来很受欢迎,但我听说设置有点麻烦 - 我不需要任何花哨的东西,只需要连接到返回JSON的REST API服务,所以我觉得NSURLConnection绰绰有余.
不太清楚如何做到这一点,特别是因为我的目标是iOS4和iOS5,而据我所知,iOS 5 SDK引入了NSURLConnectionDelegate(不确定它们有多么不同?).
我最初关注这篇文章https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html.但我有一些疑问,因为它显然在顶部说:MAC OSX Developer Library而不是iOS Developer Library.
谁能指出我正确的方向?任何示例或教程?
我的模型和集合看起来像这样.
var MyModel= Backbone.Model.Extend({
foo: function(){
alert("is not working...");
}
});
var MyCol = Backbone.Collection.extend({
models:MyModel,
url: function(){ return '/json_from_server' }, //json data mapped to MyModel
poo:function(){
alert("this works");
}
});
cols = new MyCol();
cols.fetch({
success:function () {
cols.poo(); //this works fine
cols.models.forEach(function(item){
alert(item.get("id")); //It works fine
alert(item.foo()); // this is not working...
});
}
});
Run Code Online (Sandbox Code Playgroud)
当调用item.foo()时,浏览器抛出错误:Uncaught TypeError:Object [object Object]没有方法'foo'任何人都可以帮我弄清楚这里出了什么问题.
如标题中所述,我正在尝试编写一个后台脚本,该脚本将侦听来自popup.js或contentscript.js的加载请求.当它收到一个加载时,它获取chrome.storage.local的内容,执行一些数据处理(for循环)并将其发送给请求者.
当前的问题,是我的代码收到请求,但无法发回数据.我的代码如下:
popup.js:
chrome.runtime.sendMessage({greeting: "Load"}, function(response) {
console.log(response);
}
Run Code Online (Sandbox Code Playgroud)
background.js:
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if(request.greeting=='Load') {
chrome.storage.local.get(null,function(storeObject){
var newList=[];
//Perform some dataprocessing to store part of storeObject into newList
sendResponse(newList);
});
}
});
Run Code Online (Sandbox Code Playgroud)
我认为这个问题与范围有关,因为调试后看起来像sendResponse试图从chrome.storage而不是background.js发送.此外,如果我在chrome.storage.local回调之外(之前/之后)发送消息,popup.js会收到消息.无论如何,我很遗憾该怎么做才能使此消息通过工作,并希望得到任何帮助.
我要在安装扩展程序后启动这些选项。这是我在这种情况下尝试使用的许多解决方案。
我的问题chrome.runtime.onInstalled是未定义。这是我的源代码:
background.js
if(typeof chrome.runtime.onInstalled !== 'undefined')
{
chrome.runtime.onInstalled.addListener(function (details)
{
//if(details.reason == 'update') window.open(chrome.extension.getURL('options.html'));
if(details.reason == 'install') window.open(chrome.extension.getURL('options.html'));
});
}
Run Code Online (Sandbox Code Playgroud)
我的manifest.json
{
"name": "Context Menu 2.0 for Google Translate™",
"short_name": "Translate",
"version": "1.0.0.4",
"manifest_version": 2,
"description": "Creates a context menu option to translate selected texts to a specified language",
"icons": {
"16": "trans_16.png",
"64": "trans_64.png",
"128": "trans_128.png"
},
"content_scripts": [
{
"matches":
[
"http://*/*", "https://*/*"
],
"js": ["background.js"]
}
],
"options_page": "options.html",
"background": {
"scripts": ["background.js"]
}, …Run Code Online (Sandbox Code Playgroud) 有没有办法在chrome向服务器/网页发送请求之前执行操作?
chrome会抛出我的扩展程序可以捕获的某个事件,并在必要时阻止服务器连接吗?
javascript ×5
backbone.js ×3
google-api ×2
rest ×2
gmail-api ×1
google-apps ×1
ios4 ×1
ios5 ×1
jquery ×1
json ×1
model ×1
relationship ×1
xcode4.2 ×1