我正在使用以下代码在 Facebook 中使用 android 进行检查:
private void checkin(){
String access_token = mPrefs.getString("access_token", null);
Bundle params = new Bundle();
params.putString("access_token", access_token);
JSONObject place = new JSONObject();
try {
place.put("location", location.toString());
place.put("name", name);
place.put("id", id);
} catch (JSONException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Log.i("place", place.toString());
params.putString("place", place.toString()); // YOUR PLACE ID
params.putString("message","I m here in this place");
JSONObject coordinates = new JSONObject();
try {
coordinates.put("latitude", Latitude);
coordinates.put("longitude", Longitude);
} catch (JSONException e) {
e.printStackTrace();
}
params.putString("coordinates",coordinates.toString());
params.putString("tags", "xxxx");//where xx indicates the User Id
String response="";
try {
response = facebook.request("me/checkins", params, "POST");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Log.d("Response",response);
}
但是在签入期间我收到一个错误为::
{"error":{"message":"(#114) An id must be a valid ID string (e.g., \"123\")","type":"OAuthException","code":114}}
这就是我获取页面 url 是我的 FB 页面 URL 的位置详细信息的方式:
try {
String response = facebook.request(pageURL);
Log.i("Facebook Page Response ", response);
JSONObject jobj = new JSONObject(response);
location = new JSONObject(jobj.getString("location"));
Latitude = location.getString("latitude");
Longitude = location.getString("longitude");
id = jobj.getString("id");
name = jobj.getString("name");
Log.i("Latitude", location.getString("latitude"));
Log.i("Longitude", location.getString("longitude"));
Log.i("id", jobj.getString("id"));
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (JSONException e) {
e.printStackTrace();
}
请帮助我,我对使用 Facebook api 非常陌生。