我正在通过YouTube API访问用户喜爱的视频.如何获得将每个视频标记为收藏的日期/时间?
更新:
有人指出,YouTube API文档说用户最喜欢的Feed上的"已发布"日期会有用户将视频标记为收藏的时间.但这似乎是错误的.
例如,看看这个视频条目:
http://gdata.youtube.com/feeds/api/videos/g2981r_MtHQ
它有一个"已发布"的日期2008-03-19T21:09:09.000Z.
现在让我们在一些用户喜爱的Feed中看到相同的视频:
http://gdata.youtube.com/feeds/api/users/KeepWatchingTheSkies/favorites
它有一个"已发布"的日期2008-03-19T21:09:09.000Z.相同.
以下是获取收藏Feed的不同方法:
http://gdata.youtube.com/feeds/base/users/KeepWatchingTheSkies/favorites
我们还有一个"已发布"的日期2008-03-19T21:09:09.000Z.
假设用户没有足够快地在相同的毫秒内发布视频,那么在YouTube文档中写的内容可能是错误的,并且这不是用户将视频标记为收藏的时间.
所以我的问题是:如何让用户将视频标记为收藏?
我正在尝试使用我从django-social-auth获取的OAuth令牌来访问用户日历.
所以在我设置的django-social-auth配置中:
GOOGLE_CONSUMER_KEY = 'anonymous'
GOOGLE_CONSUMER_SECRET = 'anonymous'
GOOGLE_OAUTH_EXTRA_SCOPE = ['https://www.google.com/calendar/feeds/']
Run Code Online (Sandbox Code Playgroud)
当用户从谷歌回来时,我在数据库中得到一个如下所示的条目:
{u'access_token': u'oauth_token_secret=vvvv&oauth_token=xxxx'}
Run Code Online (Sandbox Code Playgroud)
但现在,当我尝试做这样的事情时:
import gdata.calendar.client
client = gdata.calendar.client.CalendarClient()
client.auth_token = gdata.gauth.OAuthHmacToken('anonymous', 'anonymous', 'xxxx', 'vvvv', gdata.gauth.ACCESS_TOKEN)
client.GetOwnCalendarsFeed()
Run Code Online (Sandbox Code Playgroud)
我总是得到:
gdata.client.Unauthorized: Unauthorized - Server responded with: 401
<HEAD>
<TITLE>Token invalid - Invalid AuthSub token.</TITLE>
</HEAD>
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
我使用以下代码将.mov文件上传到youtube.它上传成功但视频没有任何音频.如果我做错了,请告诉我....
- (void)uploadVideoFile {
NSString *devKey = @"AI39si4w9QSgQj1JzNxzuiHhFbTm2iLt3mRerGh0UNvlryRPGgQhgIaJA8l95j4YwdC1jBIz6_JaX8eJm2GMgE06FtvIu7E9Sg";
GDataServiceGoogleYouTube *service = [self youTubeService];
[service setYouTubeDeveloperKey:devKey];
NSString *username = txtYName.text;
NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username];
// load the file data
NSString *path = [[NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/movie.mov"]] retain];
NSData *data = [NSData dataWithContentsOfFile:path];
NSString *filename = [path lastPathComponent];
// gather all the metadata needed for the mediaGroup
NSString *titleStr = txtName.text;
GDataMediaTitle *title = [GDataMediaTitle textConstructWithString:titleStr];
NSString *categoryStr = @"Comedy";
GDataMediaCategory *category = [GDataMediaCategory mediaCategoryWithString:categoryStr];
[category setScheme:kGDataSchemeYouTubeCategory];
NSString *descStr = @"this is …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过Google .Net GData客户端库生成OAuth访问令牌.我一直在使用http://code.google.com/apis/gdata/docs/auth/oauth.html中的说明作为指导,所有内容一直在进行,直到我尝试拨打电话OAuthUtil.GetAccessToken( parameters ),我收到了"(400) )错误请求"网络例外.
不幸的是,它没有告诉我为什么这是一个糟糕的请求.所以,我对此感到困惑.我唯一的想法就是,因为我使用的是localhost网址,但它不起作用(虽然我已经在Google API控制台中注册了网址,但这样做似乎没问题).
我在这里做错了什么以及我应该做些什么才能做到正确?
该OAuthParameters对象被创建像这样(的敏感数据被审查,希望并不能使它很难回答):
BaseProperties:
oauth_consumer_key: <CLIENT_KEY>,
oauth_nonce: <NONCE>
oauth_signature_method: HMAC-SHA1
oauth_timestamp: 1330440325
oauth_token: <TOKEN>
oauth_verifier: <VERIFIER>
Callback: "http://localhost:57381/subscription_auth.aspx?c=google.calendar"
ConsumerKey: <CLIENT_KEY>
ConsumerSecret: <CLIENT_SECRET>
ExtraProperties
oauth_consumer_secret: <CLIENT_SECRET>
scope: https://docs.google.com/calendar/feeds/
oauth_callback: http://localhost:57381/subscription_auth.aspx?c=google.calendar
Nonce: <NONCE>
Scope: "https://docs.google.com/calendar/feeds/"
Signature: NULL
SignatureMethod: "HMAC-SHA1"
Timestamp: "1330440325"
Token: <TOKEN>
TokenSecret: NULL -- No Token Secret was returned from the callback.
Verifier: <VERIFIER>
Run Code Online (Sandbox Code Playgroud)
这转换为Web响应的标题,如下所示:
Authorization: OAuth oauth_version="1.0",
oauth_nonce=<NONCE>,
oauth_timestamp="1330441324",
oauth_consumer_key=<CLIENT_KEY>, …Run Code Online (Sandbox Code Playgroud) 我正在访问YouTube上的gData Api.我将使用此xml作为参考.
我在一个子SimpleXMLElement对象上使用xpath,而不是只搜索子元素及其子元素的xpath,它似乎仍然是从根目录搜索.
我有以下代码:
<?php
date_default_timezone_set('Australia/Sydney');
$url = "http://gdata.youtube.com/feeds/api/playlists/58FD3A7244B64B99?prettyprint=true&alt=atom&v2=1&fields=title,subtitle,logo,entry%28link%5B@rel=%27alternate%27%5D,id,title,content,author,yt:statistics%29";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true );
$rawResponse = curl_exec($curl);
$xmlData = simplexml_load_string($rawResponse);
$xmlData->registerXPathNamespace('yt', 'http://gdata.youtube.com/schemas/2007');
foreach($xmlData->entry as $entry) {
var_dump($entry->asXml());
myFunction($entry); die();
}
function myFunction(SimpleXMLElement $xml)
{
var_dump($xml->xpath("//yt:statistics"));
}
Run Code Online (Sandbox Code Playgroud)
而不是预期的:
string(666) "<entry>
<id>http://gdata.youtube.com/feeds/api/playlists/58FD3A7244B64B99/PLlwIr0olq0UxVV_ouqclCE0xRZvs2Lytl</id>
<title type="text">Zero Punctuation on The Escapist</title>
<content type="text">Zero Punctuation picks apart the games so you don't have to. View new episodes every Wednesday only
at http://www.escapistmagazine.com</content>
<link rel="alternate" type="text/html" href="http://www.youtube.com/watch?v=7EpzwuZOvKY&feature=youtube_gdata"/>
<author>
<name>theescapistmagazine</name>
<uri>http://gdata.youtube.com/feeds/api/users/theescapistmagazine</uri> …Run Code Online (Sandbox Code Playgroud) 希望获取给定视频的所有评论,而不是一次只能翻页.
from gdata import youtube as yt
from gdata.youtube import service as yts
client = yts.YouTubeService()
client.ClientLogin(username, pwd) #the pwd might need to be application specific fyi
comments = client.GetYouTubeVideoComments(video_id='the_id')
a_comment = comments.entry[0]
Run Code Online (Sandbox Code Playgroud)
上面的代码让你抓住一条评论,可能是最近的评论,但我正在寻找一种方法来立即获取所有评论.Python的gdata模块可以实现吗?
我正在尝试使用Google Calendar API v3创建日历,如果它还不存在的话.我的实现成功检索了我的所有日历和事件,并可以更改日历,但我正在努力添加新日历.这是我为了尝试为用户添加新日历而做的事情:
...
var calendarService = new CalendarService(_authenticator);
var calendarId = "com.somedomain.somename.1234"; // Some random ID
try {
calendarManager.GetCalendar(calendarId); // No calandar found
} catch(GoogleCalandarServiceProxyException e){
// Ok, so far so good, calendar not found (that is correct) and I am here
var someCalendar = new Google.Apis.Calendar.v3.Data.CalendarListEntry {
Summary = "Some summary!",
Description = "A calendar descr.",
AccessRole = "writer",
BackgroundColor = "#E7323C",
Id = calendarId
};
calendarService.CalendarList.Insert(someCalendar).Fetch(); // Fetch to execute
}
Run Code Online (Sandbox Code Playgroud)
请求生成:
insert @ https://www.googleapis.com/calendar/v3/users/me/calendarList?alt=json&prettyPrint=true
Run Code Online (Sandbox Code Playgroud)
RequestError: …
在我的应用程序中,我使用libGoogleAdMobAds.a和libGDataTouchStaticLib.a在YouTube上进行广告和视频共享,但它显示了libGDataTouchStaticLib.a(SBJSON.o)的体系结构i386的重复符号
如何在我的应用程序中避免此错误?
我正在尝试使用本地控制台应用程序从Google Analytics(分析)中检索数据。我无需提取到Google帐户即可提取某些数据,而仅使用API。
问题是我没有获得正确的值,而且我不确定如何格式化代码以提取正确的值。我不会在特定时间范围内检索所有访客,在这种情况下,本例中为“ 2012-01-01”-“ 2014-02-20”。在Google Analytics(分析)信息中心中查看时,实际访问者人数大约是其10倍。调试代码时,我得到的数字是15000。我在控制台中显示d.TotalResults可能是错误的,变量“ d”包含许多不同的属性。
这是我正在运行的代码:
public static void Main(string[] args)
{
var serviceAccountEmail = "MY@developer.gserviceaccount.com";
var certificate = new X509Certificate2(@"C:\Users\User\Desktop\key.p12", "notasecret", X509KeyStorageFlags.Exportable);
var credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { AnalyticsService.Scope.Analytics }
}.FromCertificate(certificate));
// Create the service.
//Twistandtango
var gas = new AnalyticsService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "TestGoogleAnalytics",
});
var r = gas.Data.Ga.Get("ga:MYProfileID", "2012-01-01", "2014-02-20", "ga:visitors");
//Specify some addition query parameters
r.Dimensions = "ga:pagePath";
r.Sort = "-ga:visitors";
r.MaxResults = 5; …Run Code Online (Sandbox Code Playgroud) 我试图在我的一个谷歌文档中运行数据查询,并且它已经工作了几个月.从昨天或前一天开始,我注意到我的脚本不再有效.Google是否更新了电子表格的API?有人找到了解决方法吗?
我的错误看起来像这样:
Traceback (most recent call last):
File "build_packer_image.py", line 311, in <module>
for index, entry in enumerate(client.GetWorksheetsFeed(doc_key).entry):
File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/gdata/spreadsheet/service.py", line 129, in GetWorksheetsFeed
converter=gdata.spreadsheet.SpreadsheetsWorksheetsFeedFromString)
File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/gdata/service.py", line 1074, in Get
return converter(result_body)
File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/gdata/spreadsheet/__init__.py", line 411, in SpreadsheetsWorksheetsFeedFromString
xml_string)
File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/atom/__init__.py", line 93, in optional_warn_function
return f(*args, **kwargs)
File "/build/toolchain/mac-10.5-32/lib/python2.7/site-packages/atom/__init__.py", line 127, in CreateClassFromXMLString
tree = ElementTree.fromstring(xml_string.replace('doctype','DOCTYPE'))
File "<string>", line 125, in XML
cElementTree.ParseError: no element found: line 1, column 0
Build step 'Execute shell' marked build as failure …Run Code Online (Sandbox Code Playgroud)