Android: 如果我知道图片的名称,如何在 public Facebook 页面上获取图片 link
Android: How can I get an image link on public Facebook page if I have its name
如果我在 public 自动生成的 Facebook 页面上知道图片的名称 (safe_image.php.jpg),我如何才能直接 link 访问该图片? enter link description here 当然是使用代码
谢谢:)
编辑 1:
我在这个Graph API Reference /{user-id}/picture的帮助下实现了它但是在jason中返回的图片url总是50x50 px,这是我的请求代码:如何将返回的大小更改为更大?
params.putString("height", "200");
params.putString("type", "normal");
params.putString("width", "200");
params.putString("fields", "picture");
new Request(session, "103139833059656", params, HttpMethod.GET, new Request.Callback()
是 - 假设您有页面 ID 是可能的。考虑这个 Facebook 页面:
https://www.facebook.com/BCBlood
您有 ID - 是:
148255255232181
现在您需要做的就是调用以下行并解析响应。调用此 http get:
http://graph.facebook.com/148255255232181/picture?redirect=false&width=300&height=300
响应将是:
{
"data": {
"height": 243,
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/v/t1.0-1/10311943_731106673613700_2433559617326858334_n.jpg?oh=6f0532b666e476539b5f41b803896495&oe=5523F5C7&__gda__=1428226241_013b5598c756728eaf04d630f96256a8",
"width": 243
}
}
如您所见,响应包含个人资料图片 link。
编辑,更多详情:
Bundle params = new Bundle();
params.putString("height", "200");
params.putString("type", "normal");
params.putString("width", "200");
params.putString("redirect", "false");
Request.Callback callback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
dialog.dismiss();
FacebookRequestError error = response.getError();
if(error != null) {
Log.d("FB", "Facebook error - " + error.getErrorMessage());
Log.d("FB", "Error code - " + error.getErrorCode());
Log.d("FB", "JSON Response - " + error.getRequestResult());
Log.d("FB", "Error Category - " + error.getCategory());
} else {
GraphObject graphObject = response.getGraphObject();
JSONObject dataObject =
new JSONObject((String)graphObject.getProperty("data"));
String pictureURL =
dataObject.getString("url");
// do something with pictureURL
// ......
}
}
};
Request request= new Request(session, "103139833059656/picture", params, HttpMethod.GET, new Request.Callback()
RequestAsyncTask asyncTask = new RequestAsyncTask(request);
asyncTask.execute();
如果我在 public 自动生成的 Facebook 页面上知道图片的名称 (safe_image.php.jpg),我如何才能直接 link 访问该图片? enter link description here 当然是使用代码
谢谢:)
编辑 1:
我在这个Graph API Reference /{user-id}/picture的帮助下实现了它但是在jason中返回的图片url总是50x50 px,这是我的请求代码:如何将返回的大小更改为更大?
params.putString("height", "200");
params.putString("type", "normal");
params.putString("width", "200");
params.putString("fields", "picture");
new Request(session, "103139833059656", params, HttpMethod.GET, new Request.Callback()
是 - 假设您有页面 ID 是可能的。考虑这个 Facebook 页面: https://www.facebook.com/BCBlood
您有 ID - 是:
148255255232181
现在您需要做的就是调用以下行并解析响应。调用此 http get:
http://graph.facebook.com/148255255232181/picture?redirect=false&width=300&height=300
响应将是:
{
"data": {
"height": 243,
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-prn2/v/t1.0-1/10311943_731106673613700_2433559617326858334_n.jpg?oh=6f0532b666e476539b5f41b803896495&oe=5523F5C7&__gda__=1428226241_013b5598c756728eaf04d630f96256a8",
"width": 243
}
}
如您所见,响应包含个人资料图片 link。
编辑,更多详情:
Bundle params = new Bundle();
params.putString("height", "200");
params.putString("type", "normal");
params.putString("width", "200");
params.putString("redirect", "false");
Request.Callback callback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
dialog.dismiss();
FacebookRequestError error = response.getError();
if(error != null) {
Log.d("FB", "Facebook error - " + error.getErrorMessage());
Log.d("FB", "Error code - " + error.getErrorCode());
Log.d("FB", "JSON Response - " + error.getRequestResult());
Log.d("FB", "Error Category - " + error.getCategory());
} else {
GraphObject graphObject = response.getGraphObject();
JSONObject dataObject =
new JSONObject((String)graphObject.getProperty("data"));
String pictureURL =
dataObject.getString("url");
// do something with pictureURL
// ......
}
}
};
Request request= new Request(session, "103139833059656/picture", params, HttpMethod.GET, new Request.Callback()
RequestAsyncTask asyncTask = new RequestAsyncTask(request);
asyncTask.execute();