facebookのgraph APIを学ぼうとしています。
入門ソーシャルデータの2章(P53、例2−1)で、以下のようなコードがあり、これに基づいてリクエストを送りました。(pythonですが、urlを生成している箇所はリクエストを代入しているだけです)
# coding: utf-8 import requests # pit install requestsが必要 import json base_url = "https://graph.facebook.com/me" ACCESS_TOKEN="自分のアクセストークン" #10人の友達の10個のいいね取得 fields = "id,name,friends.limit(10).fields(likes.limit(10))" url = "%s?fields=%s&accesss_token=%s" % \ (base_url,fields,ACCESS_TOKEN,) print url content = requests.get(url).json() print json.dumps(content,indent=1)
ところが、以下のように、アクセストークンが有効ではないとエラーとなりました。
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"code": 2500,
"type": "OAuthException",
"fbtrace_id": "DIvWf5k7zpy"
}
}
googleで検索しても、おそらく初歩過ぎすぎて似たような状況のものが見つからず困っております。。。 よろしくお願いいたします。
なお、同じトークンで、graph API explorerで、idとnameを聞く(me?fields=id,name)場合はエラーとなりませんでした。
あなたの回答
tips
プレビュー