Facebook 图谱 API 搜索 Android
Facebook Graph API Searching on Android
我使用以下代码从 Facebook Graph API 检索数据并且它有效。
GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken()
, "/me"
, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
showToast(response.toString());
((TextView) findViewById(R.id.result_textview)).setText(response.toString());
}
}).executeAsync();
但是,当我使用以下在 Graph API Explorer 中有效的搜索查询时,它不再有效。
GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken()
, "/search?q=coffee&type=place"
, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
showToast(response.toString());
((TextView) findViewById(R.id.result_textview)).setText(response.toString());
}
}).executeAsync();
下面是错误json。
Response:responseCode:400,
graphObject:null,
error:{
HttpStatus:400,
errorCode:100,
errorType:GraphMethodException,
errorMessage: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api
}
}
请阅读文档。你做错了。
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"...?fields={fieldname_of_type_Location}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync()
或
GraphRequest request = GraphRequest.newGraphPathRequest(
accessToken,
"/search",
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
// Insert your code here
}
});
Bundle parameters = new Bundle();
parameters.putString("type", "place");
parameters.putString("center", "53,27");
parameters.putString("distance", "30000");
request.setParameters(parameters);
request.executeAsync();
在字段中,您可以使用国家、经度、纬度、引用等。这里是 docs
希望对您有所帮助。
我使用以下代码从 Facebook Graph API 检索数据并且它有效。
GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken()
, "/me"
, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
showToast(response.toString());
((TextView) findViewById(R.id.result_textview)).setText(response.toString());
}
}).executeAsync();
但是,当我使用以下在 Graph API Explorer 中有效的搜索查询时,它不再有效。
GraphRequest.newGraphPathRequest(AccessToken.getCurrentAccessToken()
, "/search?q=coffee&type=place"
, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
showToast(response.toString());
((TextView) findViewById(R.id.result_textview)).setText(response.toString());
}
}).executeAsync();
下面是错误json。
Response:responseCode:400,
graphObject:null,
error:{
HttpStatus:400,
errorCode:100,
errorType:GraphMethodException,
errorMessage: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api
}
}
请阅读文档。你做错了。
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"...?fields={fieldname_of_type_Location}",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync()
或
GraphRequest request = GraphRequest.newGraphPathRequest(
accessToken,
"/search",
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
// Insert your code here
}
});
Bundle parameters = new Bundle();
parameters.putString("type", "place");
parameters.putString("center", "53,27");
parameters.putString("distance", "30000");
request.setParameters(parameters);
request.executeAsync();
在字段中,您可以使用国家、经度、纬度、引用等。这里是 docs
希望对您有所帮助。