我在 android 中使用新的 facebook sdk 来获取 facebook 相册。我正在使用的代码是,
Session session = Session.getActiveSession();
Request request = new Request(null,
"https://graph.facebook.com/me/albums?access_token=" + session.getAccessToken());
Response response = Request.executeAndWait(request)
当我执行 a 时,https://graph.facebook.com/me/albums?access_token=ACCESSTOKEN
我看到了有效的Json
.
请求对象是,
{Request: session: {Session state:OPENED_TOKEN_UPDATED, token:
{AccessToken token:ACCESSTOKEN permissions:[photo_upload, publish_stream, video_upload, share_item, installed, user_photos, status_update, create_note, publish_actions]},
appId:281846961912565}, graphPath: https://graph.facebook.com/me/albums?
access_token=ACCESSTOKEN, graphObject: null, restMethod: null, httpMethod: GET, parameters: Bundle[{migration_bundle=fbsdk:20121026}]}
但是当我做 aResponse response = Request.executeAndWait(request);
我得到
{Response: responseCode: 400, graphObject: null, error: {HttpStatus: 400, errorCode: 190, errorType: OAuthException, errorMessage: Malformed access token ACCESSTOKEN?format=json}, isFromCache:false}
完整代码如下:
private class FetchUserPhotos extends AsyncTask<String, Integer, Boolean> {
private ProgressDialog pd = null;
@Override
protected void onPreExecute() {
super.onPreExecute();
pd = ProgressDialog.show(MainActivity.this, "WWD",
"Fetching photos..", true, true);
}
@Override
protected Boolean doInBackground(String... params) {
Session session = Session.getActiveSession();
Request request = new Request(null,
"https://graph.facebook.com/me/albums?access_token="
+ session.getAccessToken());
Response response = request.executeAndWait();
return true;
}
@Override
protected void onPostExecute(Boolean result) {
pd.dismiss();
}
}
你们中的任何人都可以告诉我我访问它的方式是否有问题吗?