解析android上的Facebook图形API请求时没有得到照片链接 [英] Not getting photos links when parsing Facebook graph API request on android
本文介绍了解析android上的Facebook图形API请求时没有得到照片链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Facebook SDK 4.0和图形API在Android上获取用户照片链接。
我写这段代码来解析并获取照片链接 -
I'm trying to get user photos link on android using Facebook SDK 4.0 and graph API.
I wrote this code to parse and get photos link -
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/" + userId + "/photos",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
json = response.getJSONObject();
try {
jarray = json.getJSONArray("data");
} catch (JSONException e) {
e.printStackTrace();
}
for(int i = 0; i < jarray.length(); i++){
try {
URL1 = json.getString("url");
info.setText(URL1.toString());
Log.d("got URLSSSs", URL1.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}
).executeAsync();
但它既没有显示任何错误也没有获取任何URL /链接。任何人都可以告诉我们这里有什么不对吗?
But its neither showing any error nor getting any URLs/links. Can anyone tell whats wrong here ?
推荐答案
取代
URL1 = json.getString(url);
with
URL1 = oneAlbum.getString(source);
现在有效。
Replaced
URL1 = json.getString("url");
with
URL1 = oneAlbum.getString("source");
It works now.
这篇关于解析android上的Facebook图形API请求时没有得到照片链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文