我正在尝试编写一个小工具,将图片从Google App Engine上传到Picasa.获取图像有效,但是当我尝试上传它时,我得到错误" TypeError:stat()参数1必须是(没有NULL字节的编码字符串),而不是str "
该代码基本上如下所示:
def getfile(url):
result = urlfetch.fetch(url)
if result.status_code == 200:
return (result.content)
logging.error ("[-] Error fetching URL: %s" % url)
def uploadpicture(comment,pic):
album_url = '/data/feed/api/user/%s/album/%s' % (username, album)
fname = "image.jpg"
entry = gd_client.InsertPhotoSimple(album_url, fname, comment, pic, content_type='image/jpeg')
picurl = "http://brilliantleap.com/blog/frog.jpg"
pic = getfile(picurl)
comment = "Test"
uploadpicture(comment, pic)
Run Code Online (Sandbox Code Playgroud)
完整的Stacktrace是:
Traceback(最近一次调用最后一次):
在调用 handler.get(*groups)中输入文件"/ home/birt/stuff/google/appengine/ext/webapp/init .py",第507行
文件"/home/birt/stuff/app_picasaupload/main.py",第124行,获取uploadpicture(评论,pic)
在uploadpicture entry = gd_client.InsertPhotoSimple(album_url,fname,comment,pic,content_type ='image/jpeg')中输入文件"/home/birt/stuff/app_picasaupload/main.py",第104行
在InsertPhotoSimple content_type中输入文件"/home/birt/stuff/app_picasaupload/gdata/photos/service.py",第469行
在InsertPhoto中输入文件"/home/birt/stuff/app_picasaupload/gdata/photos/service.py",第398行os.path.exists(filename_or_handle):#这是一个文件名
文件"/usr/lib/python2.5/posixpath.py",第171行,存在st = os.stat(path)
文件"/home/birt/stuff/google/appengine/tools/dev_appserver.py",1109,在通话 如果不是FakeFile.IsFileAccessible(路径):
文件"/home/birt/stuff/google/appengine/tools/dev_appserver.py",第1018行,IsFileAccessible normcase = …
如何获取谷歌搜索结果网址?
(我使用Zend_Gdata_Gbase获取搜索谷歌搜索结果而不是DomDocument/htmlsimpleparser,因为它看起来Zend_Gdata_Gbase专门用于解析谷歌搜索结果.如果我的选择错误,请写.)
我的功能是获取'yahoo'或其他查询搜索字符串的google搜索结果:( 该函数获取的搜索结果应该包含'yahoo'字样,但是当我使用prin_t($ feed)时,我看不到网址每个结果)
<?php
function queryGoogleSearch($queryString='yahoo'){
$service = new Zend_Gdata_Gbase();
$query = $service->newSnippetQuery();
$query->setBq('['.$queryString.']');
$query->setOrderBy('modification_time');
$query->setSortOrder('descending');
$query->setMaxResults('4');
$feed = $service->getGbaseSnippetFeed($query);
return $feed;
}
print_r(queryGoogleSearch());
?>
Run Code Online (Sandbox Code Playgroud)
我得到4个第一个网址结果(当我在谷歌手动搜索时):
www.yahoo.com,mail.yahoo.com,search.yahoo.com,maps.yahoo.com
但是当我打印$ feed变量时,我找不到它们.
请问我应该更改或添加inqueryGoogleSearch()函数?(或其他更好的代码)
谢谢
我使用私人共享链接查看我的用户个人页面中的日历,但现在谷歌决定更改内容https://www.google.com/support/calendar/bin/answer.py?answer=1631300
假设我有用户的密码和用户名.我可以使用Zend Framework登录Google帐户并添加活动或内容,但如何登录Google并登录浏览器(注入cookie或其他内容,就像用户访问gmail一样,他已经登录) .
这样,用户将看到他自己的日历,并且不会收到任何警告.
UPDATE
如果我有他的Gmail(或谷歌)帐户的用户/密码,我如何在iframe中显示日历(即使只读也可以)
我想访问Google分析数据,我从Google数据API SDK获取样本.但是这些编码不起作用并抛出异常
请求的执行失败:https://www.google.com/analytics/feeds/accounts/default
所以我发现原因是Google将其更新为v3.0.我搜索了C#的更新编码,但我找不到解决方案.
我有同样的问题,但用C#. 使用GData .NET Analytics API时抛出异常
我尝试使用以下更改进行编码,如Google开发者所述 - https://developers.google.com/analytics/resources/articles/gdata-migration-guide#appendix_a
string userName = this.Username.Text;
string passWord = this.Password.Text;
AnalyticsService service = new AnalyticsService("AnalyticsSampleApp");
service.setUserCredentials(userName, passWord);
string googleAccountWebId = "AIXXXXXXXXXXXXXXXXXXXXXXXXXXX";
string profileFeedUrl = "https://www.googleapis.com/analytics/v2.4/data?key=" + googleAccountWebId;
DataQuery query2 = new DataQuery(profileFeedUrl);
query2.Ids = "12345678";
query2.Metrics = "ga:visits";
query2.Sort = "ga:visits";
query2.GAStartDate = DateTime.Now.AddMonths(-1).AddDays(-2).ToString("2011-08-01");
query2.GAEndDate = DateTime.Now.ToString("2013-09-01");
query2.StartIndex = 1;
DataFeed data = service.Query(query2);
foreach (DataEntry entry in data.Entries)
{
string st=entry.Metrics[0].Value;
}
Run Code Online (Sandbox Code Playgroud)
但即使我改变它,它也会抛出异常
DataFeed data = …
我正在将用户输入到本地标志的python应用程序中.有了这些数据,我试图使用Google地图获取其对象的经度和纬度.我正在尝试使用Google gdata api来处理这些地图,但是当我在python中工作时,我找不到从搜索查询中获取长数据和拉取数据的方法.
我可以使用任何能在python中解决我的问题的系统.
我正在尝试使用Google的.NET Calendar API 检索南非公众假期.
我有以下问题:
EventQuery范围.(在给定日期范围之前和之后)我通过在线查看确认了这个特定的公共日历具有正确的日期.
我最好的猜测是我错误地使用了API,并且我正在查询日历条目的创建/更新日期而不是事件日期.
码:
var feedUrl = "http://www.google.com/calendar/feeds/en.sa%23holiday%40group.v.calendar.google.com/public/full";
var service = new CalendarService("My application name");
var qry = new EventQuery(feedUrl);
qry.StartDate = new DateTime(2011, 1, 1);
qry.EndDate = new DateTime(2012, 1, 1);
EventFeed results = service.Query(qry);
foreach (EventEntry entry in results.Entries)
{
if (entry.Times.Count == 0)
continue;
// Using entry.Times[0].StartTime results in
// missing data and data outside of the given search criteria.
}
Run Code Online (Sandbox Code Playgroud)
我使用的是最新的Google .NET Data …
我似乎只能下载已弃用的gdata版本的zip文件.我在哪里可以找到今天的版本(作为zip文件!)?谢谢
我将基于浏览器上传的示例YouTube api代码复制并粘贴到我的网站,但是当我将类别更改为"游戏"时,它会显示错误的请求错误.
这是示例代码:
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$myVideoEntry->setVideoTitle('My Test Movie');
$myVideoEntry->setVideoDescription('My Test Movie');
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory('Autos');
// Set keywords. Please note that this must be a comma-separated string
// and that individual keywords cannot contain whitespace
$myVideoEntry->SetVideoTags('cars, funny');
$tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
$tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
$tokenValue = $tokenArray['token'];
$postUrl = $tokenArray['url'];
Run Code Online (Sandbox Code Playgroud)
但是,当我改变
$myVideoEntry->setVideoCategory('Autos');
Run Code Online (Sandbox Code Playgroud)
至
$myVideoEntry->setVideoCategory('Gaming');
Run Code Online (Sandbox Code Playgroud)
我明白了..
Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 <?xml version='1.0' encoding='UTF-8'?><errors><error><domain>yt:validation</domain><code>invalid_value</code><location type='xpath'>media:group/media:category[@scheme='http://gdata.youtube.com/schemas/2007/categories.cat']/text()</location></error></errors> …Run Code Online (Sandbox Code Playgroud) 我正在使用gdata-python-client库(http://code.google.com/p/gdata-python-client/)将联系人插入Google帐户.当我设置这样的性别时:
google_contact.gender = gdata.contacts.data.Gender(text="Male")
Run Code Online (Sandbox Code Playgroud)
它实际上是在"目录服务器"字段中的联系人上设置的.
任何想法为什么会这样?
如果它影响任何事情,我的代码将在Google App Engine开发服务器上运行.
我正在开始查看Google Analytics核心报告API,该API现已发布于版本3.
根据文档,我可以使用链接http://code.google.com/apis/analytics/docs/gdata/v3/gdataLibraries.html中列出的一个客户端库.
我正在使用python,所以我在寻找在python中使用核心报告API的示例,但我找不到使用这个库的人.http://code.google.com/p/google-api-python-client/wiki/SampleApps上的所有示例都不包含Core Reporting API的示例.
另一种选择似乎是使用该库在http://code.google.com/p/gdata-python-client/,但我不知道该库使用核心API报告的最新版本(3.0版).
我正在寻找符合http://code.google.com/apis/analytics/docs/gdata/v3/reference.html的python库(包含文档/示例)
谢谢
gdata-api ×10
python ×4
gdata ×3
php ×3
zend-gdata ×2
.net ×1
c# ×1
google-maps ×1
objective-c ×1
picasa ×1
typeerror ×1
youtube-api ×1