所以我试图同步到谷歌文档,而不必询问用户他的凭据.我使用此代码获取auth-token:
AccountManager mgr = AccountManager.get(activity);
authToken = mgr.blockingGetAuthToken(account, DocsService.DOCS_SERVICE, true);
Run Code Online (Sandbox Code Playgroud)
这将返回一个看起来格式良好的身份验证令牌.所以在我的DocsService上运行:
service.setAuthSubToken(authToken);
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用API时,我只获得了AuthenticationException.有关如何处理此错误的任何想法?
编辑:我确实拥有USE_CREDENTIALS权限.
我收到以下错误:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.of([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableTypes(AltFormat.java:399)
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableXmlTypes(AltFormat.java:387)
at com.google.gdata.wireformats.AltFormat.<clinit>(AltFormat.java:49)
at com.google.gdata.client.Service.<clinit>(Service.java:558)
at testproject.TestProject.run(TestProject.java:22)
at testproject.TestProject.main(TestProject.java:31)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Run Code Online (Sandbox Code Playgroud)
这来自以下代码:
package testproject;
import com.google.gdata.client.youtube.YouTubeService;
import com.google.gdata.util.*;
import java.util.logging.*;
public class TestProject {
public static void main(String[] args) {
try {
YouTubeService service = new YouTubeService("Test", "developerKey");
service.setUserCredentials("root@gmail.com", "pa$$word");
} catch (AuthenticationException ex) {
Logger.getLogger(TestProject.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Run Code Online (Sandbox Code Playgroud)
起初,我在http://code.google.com/p/gdata-java-client/downloads/list中包含了每个库,并且还导入了比我需要的更多的库.我已经删除了我认为不必要的库(感谢thinksteep).所以我目前包含的库是以下库:
mail.jar
activation.jar
ant.jar
gdata-core-1.0.jar
gdata-media-1.0.jar
guava-11.0.1.jar
gdata-youtube-2.0.jar …Run Code Online (Sandbox Code Playgroud) 我想从我的Google Picasa帐户中获取相册列表.我试过这个指南.问题是它成功验证但没有返回任何相册(请参阅下面的代码).我还是可以发一张新专辑.
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import com.google.gdata.client.photos.PicasawebService;
import com.google.gdata.data.PlainTextConstruct;
import com.google.gdata.data.photos.AlbumEntry;
import com.google.gdata.data.photos.UserFeed;
import com.google.gdata.util.AuthenticationException;
import com.google.gdata.util.ServiceException;
public class Test {
public static void main(String[] args) {
String username = "myusername";
String password = "mypassword";
PicasawebService service = new PicasawebService("myapp");
try {
// Get list of albums. (AUTHENTICATION SUCCESSFUL BUT NO ALBUM RETURNED)
service.setUserCredentials(username, password);
URL url = new URL("https://picasaweb.google.com/data/feed/api/user/" + username + "?kind=album");
UserFeed feed = service.getFeed(url, UserFeed.class);
List<AlbumEntry> albums …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用GData API从我的iPhone应用程序内部向youtube发布视频.这是我正在使用的代码:
GDataServiceGoogleYouTube* service = [self youTubeService];
[service setYouTubeDeveloperKey:youtubeAppKey];
NSString *username = service.username;
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username];
NSData *data = [NSData dataWithContentsOfFile:self.videoPath];
NSString *filename = @"My Cool Video";
NSString *titleStr = @"Title";
GDataMediaTitle *mediaTitle = [GDataMediaTitle textConstructWithString:titleStr];
NSString *categoryStr = @"Comedy";
GDataMediaCategory *mediaCategory = [GDataMediaCategory mediaCategoryWithString:categoryStr];
[mediaCategory setScheme:kGDataSchemeYouTubeCategory];
NSString *descStr = @"Description";
GDataMediaDescription *mediaDesc = [GDataMediaDescription textConstructWithString:descStr];
NSString *keywordsStr = @"iOS";
GDataMediaKeywords *mediaKeywords = [GDataMediaKeywords keywordsWithString:keywordsStr];
GDataYouTubeMediaGroup *mediaGroup = [GDataYouTubeMediaGroup mediaGroup];
[mediaGroup setMediaTitle:mediaTitle];
[mediaGroup setMediaDescription:mediaDesc];
[mediaGroup addMediaCategory:mediaCategory];
[mediaGroup setMediaKeywords:mediaKeywords]; …Run Code Online (Sandbox Code Playgroud) 好的,周末就是这个 - 这是我最后一个星期天晚上的求助电话.
必须使用2 Legged OAUTH aproach的Google Marketplace应用需要将50K记录写入Google Doc电子表格.我能够创建,调整大小,重命名和将记录写入电子表格.单独写100行需要一分钟,所以我必须使用批量更新.无法让批量更新工作.下面的代码是我最好的尝试 - 我一直得到"令牌无效 - 令牌401无效".所有示例代码都是针对三条腿的oauth - 但我不能提示用户批准该应用程序,因为它是一个市场应用程序
使用openid和2LO找到批量电子表格更新的示例会很棒
final String SCOPE = "https://spreadsheets.google.com/feeds/spreadsheets/private/full";
SpreadsheetService spreadsheetService;
String consumerKey = getInitParameter("consumer_key");
String consumerSecret = getInitParameter("consumer_secret");
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey(consumerKey);
oauthParameters.setOAuthConsumerSecret(consumerSecret);
oauthParameters.setOAuthType(OAuthParameters.OAuthType.TWO_LEGGED_OAUTH);
oauthParameters.setScope(SCOPE);
OAuthSigner signer = new OAuthHmacSha1Signer();
spreadsheetService = new SpreadsheetService("nimbits-com");
String title = entity.getName().getValue();
try {
spreadsheetService.setOAuthCredentials(oauthParameters, signer);
spreadsheetService.setProtocolVersion(SpreadsheetService.Versions.V3);
SpreadsheetQuery query = new SpreadsheetQuery(new URL(SCOPE));
query.addCustomParameter(new Query.CustomParameter("xoauth_requestor_id", user.getEmail().getValue()));
query.setTitleQuery(title);
SpreadsheetFeed feed = spreadsheetService.query(query, SpreadsheetFeed.class);
//works fine up to this point, I …Run Code Online (Sandbox Code Playgroud) 我正在使用gdata-python-client从 Google 电子表格中读取数据。我读取行的代码如下:
import gdata.speadsheet.text_db
gd_client = gdata.spreadsheet.text_db.DatabaseClient(
username=setting['account_name'],
password=setting['account_pass'])
xls_db = gd_client.GetDatabases(spreadsheet_key=setting['spreadsheet_id'])
first_sheet = xls_db[0].GetTables()[0]
entries = first_sheet.GetRecords(1, 200)
Run Code Online (Sandbox Code Playgroud)
比方说,电子表格有160行和12个行是空的。当我尝试使用上述代码读取所有 160 行时,它只读取前 11 行(即,直到它获得空的第12行)。如果电子表格没有任何空行,代码将读取所有 160 行。
当我尝试从空行读取下一行时,它不返回任何内容。例如:
entries = first_sheet.GetRecords(50, 55) # entries is None
Run Code Online (Sandbox Code Playgroud)
如何从包含空行的 Google 电子表格中读取所有行。
任何帮助,将不胜感激。
对于我使用PHP构建的YouTube网络应用程序,我有简单的视频播放器,嵌入了一个<iframe>,然后是一个<div>有关当前加载的视频(描述,ID,标题等)的信息.
A <ul>包含从YouTube使用PHP gData API获取的视频列表,每个视频都<li>包含一个链接,用于激活JavaScript以将视频播放器更改为正确的视频,还可以更新页面上的视频信息.
问题在于:gData为视频描述返回多行,非转义序列,但在JavaScript中不起作用.我应该如何删除换行符并将其替换为<br>(注意它们不是换行符\n,它们是实际的换行符和换行符).
我还必须逃避在JavaScript字符串中无效的其他内容,例如撇号字符'.做这个的最好方式是什么?
我正在开发一个cocos2d应用程序,我需要集成youtube API才能将视频上传到youtube.我已经集成了从这里下载的gdata api .并更改了项目设置如下.
设置其他链接器标志:-lxml2
其他C标志:-DDEBUG = 1
C语言方言:C99 [-std = c99]
添加了标题搜索路径:/ usr/include/libxml2并添加了libxml2.dlyb
但是当我构建项目时收到以下错误消息
Undefined symbols for architecture i386:
"_SCNetworkReachabilityCreateWithName", referenced from:
-[GDataOAuthSignIn startReachabilityCheck] in GDataOAuthSignIn.o
"_SCNetworkReachabilitySetCallback", referenced from:
-[GDataOAuthSignIn startReachabilityCheck] in GDataOAuthSignIn.o
-[GDataOAuthSignIn stopReachabilityCheck] in GDataOAuthSignIn.o
"_SCNetworkReachabilityScheduleWithRunLoop", referenced from:
-[GDataOAuthSignIn startReachabilityCheck] in GDataOAuthSignIn.o
"_SCNetworkReachabilityUnscheduleFromRunLoop", referenced from:
-[GDataOAuthSignIn stopReachabilityCheck] in GDataOAuthSignIn.o
"_SecItemCopyMatching", referenced from:
-[GDataOAuthKeychain passwordForService:account:error:] in GDataOAuthViewControllerTouch.o
"_SecItemDelete", referenced from:
-[GDataOAuthKeychain removePasswordForService:account:error:] in GDataOAuthViewControllerTouch.o
"_SecItemAdd", referenced from:
-[GDataOAuthKeychain setPassword:forService:account:error:] in GDataOAuthViewControllerTouch.o
"_kSecAttrAccount", referenced from:
+[GDataOAuthKeychain keychainQueryForService:account:] …Run Code Online (Sandbox Code Playgroud) 我的项目使用ARC,我想使用不兼容ARC的GDATA api.我知道如何为单个文件禁用ARC(通过为这些文件添加-fno-objc-arc编译器标志).但是在GDataObject.h文件中有一个结构防御
typedef struct GDataDescriptionRecord {
NSString *label;
NSString *keyPath;
enum GDataDescRecTypes reportType;
} GDataDescriptionRecord;
Run Code Online (Sandbox Code Playgroud)
它会导致错误
ARC forbids object in struct or union
Run Code Online (Sandbox Code Playgroud)
我怎样才能避免这个问题.是否有任何ARC兼容的GDATA api可用或以任何方式禁用.h文件的弧