2

私はただ学んでいrestfbます。FB サイトにアプリを登録し、アプリ ID とシークレット キーを取得しました。ただし、このチュートリアルのように、 DefaultFacebookClientを初期化するためのアクセス トークンが必要です。そこでの指示に従おうとしましたが、アプリ ID と秘密鍵からアクセス トークンを取得する方法を十分に説明しているものはありませんでした。

Request https://graph.facebook.com/oauth/authorize?client_id=MY_API_KEY&redirect_uri=http://www.facebook.com/connect/login_success.html

Facebook will redirect you to http://www.facebook.com/connect/login_success.html?code=MY_VERIFICATION_CODE

Request https://graph.facebook.com/oauth/access_token?client_id=MY_API_KEY& redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=MY_APP_SECRET&code=MY_VERIFICATION_CODE

Facebook will respond with access_token=MY_ACCESS_TOKEN

私はまさにそれをしましたが、私が得るたびに

{
   "error": {
      "message": "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request",
      "type": "OAuthException",
      "code": 100
   }
}

アクセス トークンを取得して API の使用を開始するにはどうすればよいでしょうか?

4

3 に答える 3

3

It looks like the plugin authors assume that you will be authenticating a user with the Login Dialog or the JavaScript SDK.

Both of these methods return a user access token you can use. You need your App_ID and Secret to initialize these. Most Facebook operations require a user access token.

If you are making API calls solely to read public data, then you may be able to get away with an application access token. For this you can use the DefaultFacebookClient().obtainAppAccessToken() method of RestFB.

于 2013-03-19T01:51:45.480 に答える
1

私は同じ問題を抱えていました。

redirect_uri-parameter に末尾のスラッシュを追加すると、問題が解決しました。

また、リクエストを行うときは、Facebook の URI ではなく、独自のアプリの URI を使用していることを確認してください。

例えば:

http://www.yoursite.com

しばらくはうまくいきませんでした

http://www.yoursite.com/

やりました。

于 2013-10-12T09:21:06.927 に答える