Facebook SDK for Android 3.0 を使用しています。ユーザーの写真を取得してアプリに表示したいと考えています。参考資料、ログインに成功しました。そしてアルバムを手に入れようとします。
fqlとgraph apiの 2 つの方法を試しました。
graph_or_fql = "fql";
if (graph_or_fql.equals("fql")) {
String query = "SELECT aid, cover_pid, name, size, visible, object_id FROM album WHERE owner = "
+ userId;
Bundle params = new Bundle();
params.putString("method", "fql.query");
params.putString("query", query);
mAsyncRunner.request(null, params,
new PhotosRequestListener());
} else {
// Bundle params = new Bundle();
// params.putString("fields", "name, aid, size");
// mAsyncRunner.request("me/photos", params,
// new PhotosRequestListener());
mAsyncRunner.request("me/album",
new PhotosRequestListener());
}
/*
* callback after friends are fetched via me/friends or fql query.
*/
public class PhotosRequestListener extends BaseRequestListener {
@Override
public void onComplete(final String response, final Object state) {
dialog.dismiss();
Log.d("tag", "response: " + response);
try {
if (graph_or_fql.equals("fql")) {
jsonArray = new JSONObject(response).getJSONArray("data");
// jsonArray = new JSONArray(response);
// JSONObject jsonObj = new JSONObject(response);
// jsonArray = new JSONArray(jsonObj.getString("data"));
} else {
jsonArray = new JSONObject(response).getJSONArray("data");
}
} catch (JSONException e) {
showToast("JSONError: " + e.getMessage());
e.printStackTrace();
return;
}
gridView.setOnItemClickListener(MainActivity.this);
gridView.setAdapter(new GridViewAdapter(MainActivity.this));
}
public void onFacebookError(FacebookError error) {
dialog.dismiss();
Toast.makeText(getApplicationContext(),
"Facebook Error: " + error.getMessage(), Toast.LENGTH_SHORT)
.show();
}
}
しかし、すべてのエラー。
fql エラー メッセージ: "error_msg":"セッション キーが無効か、有効ではなくなりました"
11-07 16:41:10.956: D/tag(468): response: {"error_code":102,"error_msg":"Session key invalid or no longer valid","request_args":[{"key":"query","value":"SELECT aid, cover_pid, name, size, visible, object_id FROM album WHERE owner = 100001791736733"},{"key":"method","value":"fql.query"},{"key":"format","value":"json"}]}
11-07 16:41:10.956: W/System.err(468): org.json.JSONException: No value for data
11-07 16:41:10.966: W/System.err(468): at org.json.JSONObject.get(JSONObject.java:354)
11-07 16:41:11.015: W/System.err(468): at org.json.JSONObject.getJSONArray(JSONObject.java:544)
11-07 16:41:11.015: W/System.err(468): at com.example.facebookphoto.MainActivity$PhotosRequestListener.onComplete(MainActivity.java:144)
11-07 16:41:11.015: W/System.err(468): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:273)
グラフ API エラー メッセージ: "error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}
11-07 16:45:43.106: D/tag(538): response: {"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
11-07 16:45:43.106: W/System.err(538): org.json.JSONException: No value for data
11-07 16:45:43.156: W/System.err(538): at org.json.JSONObject.get(JSONObject.java:354)
11-07 16:45:43.156: W/System.err(538): at org.json.JSONObject.getJSONArray(JSONObject.java:544)
11-07 16:45:43.176: W/System.err(538): at com.example.facebookphoto.MainActivity$PhotosRequestListener.onComplete(MainActivity.java:149)
11-07 16:45:43.176: W/System.err(538): at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:273)
何が原因なのかわかりません。助けて、ありがとう。