3
在發佈日文信息時,可以使用facebook-python sdk句柄。 我可以張貼英文消息沒有任何問題,但是當我嘗試後日本facebook-graph sdk無法處理Unicode字符
graph.put_object("me", "feed", message=u'あなたが大好きだよ')
我得到了下面的錯誤。我該怎麼辦?
Traceback (most recent call last):
File "/base/data/home/apps/s~posttofacebook123456/1.365133296513228525/kay/app.py", line 371, in get_response
response = view_func(request, **values)
File "/base/data/home/apps/s~posttofacebook123456/1.365133296513228525/myapp/views.py", line 116, in index
graph.put_object("me", "feed", message=u'あなたが大好きだよ')
File "/base/data/home/apps/s~posttofacebook123456/1.365133296513228525/myapp/facebook.py", line 140, in put_object
post_args=data)
File "/base/data/home/apps/s~posttofacebook123456/1.365133296513228525/myapp/facebook.py", line 291, in request
post_data = None if post_args is None else urllib.urlencode(post_args)
File "/python27_runtime/python27_dist/lib/python2.7/urllib.py", line 1289, in urlencode
v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-8: ordinal not in range(128)