图片属性格式使用运行与朋友fb应用程序 [英] Picture property format using run with friends fb app
问题描述
我正在编辑Runwithfriends FB示例应用程序来构建我自己的一个。它工作正常,我在这里和那里做了一些改变。我休息了两个星期,但是现在当我尝试访问该应用程序时,我得到一个奇怪的蟒蛇错误:
I am editing the Runwithfriends FB sample app to build one of my own. It was working fine and I was making a few changes here and there. I took a break from it for about a fortnight but now when I try to access the app, I get a strange python error:
C:\Program Files\ init_facebook(self =< main .RecentRunsHandler对象>)中的Apache Software Foundation\Tomcat 7.0\webapps\ROOT\app\main.py
316 user_id = facebook。 user_id,friends = friends,
317 access_token = facebook.access_token,name = me [u'name'],
=> 318 email = me.get(u'email'),picture = me [ u'picture'])
319 user.put()
320除了KeyError,ex:
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\app\main.py in init_facebook(self=<main.RecentRunsHandler object>) 316 user_id=facebook.user_id, friends=friends, 317 access_token=facebook.access_token, name=me[u'name'], => 318 email=me.get(u'email'), picture=me[u'picture']) 319 user.put() 320 except KeyError, ex:
< ..某些部分剪辑.. >
<..some portion clipped..>
class'google.appengine.api.datastore_errors.BadValueError'>:属性图片必须是str或unicode实例,而不是dict
args =( '属性图片必须是一个str或unicode实例,而不是一个dict')
message ='正确ty图片必须是一个str或unicode实例,而不是一个dict'
class 'google.appengine.api.datastore_errors.BadValueError'>: Property picture must be a str or unicode instance, not a dict args = ('Property picture must be a str or unicode instance, not a dict',) message = 'Property picture must be a str or unicode instance, not a dict'"
我知道这是一个非常通用的错误,但它指向以下代码。这段代码一直在那里,我从来没有碰到过。我真的不知道现在在哪里看 - 我已经彻底搜索,但找不到线索。对不起,如果这还是太广泛,但是如果你能告诉我我可以提供哪些其他信息来调试这个,我会很高兴的: - (
I know this is a very generic error but its pointing to the following code. This code has always been there and I have never touched it. I really do not know where else to look now - I have searched exhaustively but couldnt find a clue. Sorry, if this is still too broad but I would be glad if you can tell me what other info can I provide to debug this :-(
def init_facebook(self):
"""Sets up the request specific Facebook and User instance"""
facebook = Facebook()
user = None
# initial facebook request comes in as a POST with a signed_request
if u'signed_request' in self.request.POST:
facebook.load_signed_request(self.request.get('signed_request'))
# we reset the method to GET because a request from facebook with a
# signed_request uses POST for security reasons, despite it
# actually being a GET. in webapp causes loss of request.POST data.
self.request.method = u'GET'
self.set_cookie(
'u', facebook.user_cookie, datetime.timedelta(minutes=1440))
elif 'u' in self.request.cookies:
facebook.load_signed_request(self.request.cookies.get('u'))
# try to load or create a user object
if facebook.user_id:
user = User.get_by_key_name(facebook.user_id)
if user:
# update stored access_token
if facebook.access_token and \
facebook.access_token != user.access_token:
user.access_token = facebook.access_token
user.put()
# refresh data if we failed in doing so after a realtime ping
if user.dirty:
user.refresh_data()
# restore stored access_token if necessary
if not facebook.access_token:
facebook.access_token = user.access_token
if not user and facebook.access_token:
me = facebook.api(u'/me', {u'fields': _USER_FIELDS})
try:
friends = [user[u'id'] for user in me[u'friends'][u'data']]
user = User(key_name=facebook.user_id,
user_id=facebook.user_id, friends=friends,
access_token=facebook.access_token, name=me[u'name'],
email=me.get(u'email'), picture=me[u'picture'])
user.put()
except KeyError, ex:
pass # ignore if can't get the minimum fields
self.facebook = facebook
self.user = user
推荐答案
可能与 2012年10月突破变化,报价:
/图片连接将返回指定回调时的字典
/picture connection will return a dictionary when a callback is specified
访问/ picture connecti时,我们将开始返回一个包含字段url,height,width和is_silhouette的字典打开一个对象并指定一个回调属性。目前,我们只是将图片URL返回为一个字符串。
We will start returning a dictionary containing the fields url, height, width, and is_silhouette when accessing the /picture connection for an object and specifying a callback property. Currently we just return the picture URL as a string.
所以在你的代码中,你正在使用 picture = me [u'picture']
,尝试访问图片的
字典(如果它有一个;我不能告诉你,如果这是适用的,因为我不知道你的代码是否被认为是指定回调属性。 url
属性
So at this point in your code, where you are currently using picture=me[u'picture']
, try accessing the url
property of the picture
dictionary instead. (If it has one; I can’t tell you for sure if this is applicable, since I don’t know if your code would be considered as having specified a callback property.)
如果我的假设是正确的,您还可以按照路线图中所述启用迁移;但这只会使您的应用程序以旧的方式工作,直到10月3日,所以可能最好立即尝试修复。
If my assumption is correct, you could also enable the migration as described in the roadmap; but that will only make your app work in the old way until Oct. 3rd, so probably better to try and fix it right away.
这篇关于图片属性格式使用运行与朋友fb应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!