我正在使用此代码。其实我想做的是,在我的墙上,我得到了一张我在这里的地图checkins
。
private void getFb()
{
fb = new Facebook(Constants.facebookKey);
String[] arrayOfString = new String[2];
arrayOfString[0] = "publish_stream";
arrayOfString[1] = "me/checkins";
fb.authorize(this, arrayOfString, new FBDialogListener());
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
fb.authorizeCallback(requestCode, resultCode, data);
}
private class FBDialogListener implements Facebook.DialogListener
{
public void onComplete(Bundle values)
{
Bundle params = new Bundle();
params.putString("place", "MyPlaceId"); // YOUR PLACE ID
params.putString("Message","I m here in this place");
JSONObject coordinates = new JSONObject();
try {
coordinates.put("latitude",Constants.latitude); // The place Coordinates
coordinates.put("longitude", Constants.longitude);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
params.putString("coordinates",coordinates.toString());
JSONArray frnd_data=new JSONArray();
fb.dialog(MainMenu.this,"me/checkins", params, new PublishDialogListener());
}
public void onFacebookError(FacebookError e) {
}
public void onError(DialogError e) {
}
public void onCancel() {
}
}
private class PublishDialogListener implements Facebook.DialogListener
{
public void onComplete(Bundle values) {
}
public void onFacebookError(FacebookError e) {
}
public void onError(DialogError e) {
}
public void onCancel() {
}
}
这只是给我错误
The page you have request is not found.
有什么问题? 最诚挚的问候
答案 0 :(得分:1)
没有me/checkins
权限,所以这是错误的:
arrayOfString[1] = "me/checkins";
您改为need the publish_checkins
permission。所以改成它:
arrayOfString[1] = "publish_checkins";
Facebook.dialog()
方法用于打开预定义的对话框,例如帖子状态或授权应用对话框。您想要直接向Graph API发出自定义请求。这可以使用Facebook.request()
方法完成,如下所示:
String jsonResponse = fb.request("me/checkins", params, "POST");
附注:Facebook SDK还为submitting requests asynchronously提供了一种便捷方法。