Bundle postParams = new Bundle();
postParams.putString("fb:app_id", "234256810031533");
postParams.putString("name", "test app");
postParams.putByteArray("picture", MainActivity.byteArray);
postParams.putString("og:type", "place");
postParams.putString("place:location:latitude", "90");
postParams.putString("place:location:longitude", "45");
postParams.putString("access_token", pageaccessToken);
/* make the API call */
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(getApplicationContext(),
error.getErrorMessage(),
Toast.LENGTH_SHORT).show();
}
else {
JSONObject graphResponse = response.getGraphObject()
.getInnerJSONObject();
@SuppressWarnings("unused")
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(TAG, "JSON error " + e.getMessage());
}
Toast.makeText(getApplicationContext(),
"Successfully Shared", Toast.LENGTH_LONG)
.show();
}
finish();
}
};
Request request = new Request(session, "/me/objects/place", postParams,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
我正在使用Facebook SDK 3.7并且我收到错误“(#100)参数对象是必需的”。如何使用经度和纬度发布带照片的地方。我无法理解请帮助我。我正在使用/me/object/place
发布带有图片的地方。
答案 0 :(得分:-2)
这适合我。
FB.api('/me/objects/[namespace]:place',
'post', {
"access_token" : FB.getAuthResponse()['accessToken'],
object: {'url': 'test',
type': '[namespace]:place',
'title': 'test',
'image': 'test'
}
},function (response) {
console.log(response);
if (!response || response.error) {
alert('Error occured');
}
}
);