6

我想使用 facebook android sdk (graph api) 签到,

我正在尝试这个

String checkinData = "{"+
                        "\"message\"=\"Test\"" +
                        "\"place\"=\"000000000\"" 
                        +   "\"coordinates\"={\"latitude\":\"000000000\", \"longitude\":\"-000000000\"}\"" + "}";

                Bundle params  = new Bundle();
                params.putString("checkin", checkinData);
                String pageData = "";

                try {
                    pageData = facebook.request("/checkins", params, "POST");
                } catch (Exception e) {

                    e.printStackTrace();
                }

                System.out.println("Data :  " + pageData);

但它给了我这个错误

{"error":{"message":"batch parameter must be a JSON array","type":"GraphBatchException"}}

这是使用facebook graph api签到的正确方法吗

4

2 回答 2

13

Simple code for checkins . Try this :

Bundle params = new Bundle();
params.putString("access_token", "YOUR ACCESS TOKEN");
params.putString("place", "203682879660695");  // YOUR PLACE ID
params.putString("message","I m here in this place");
JSONObject coordinates = new JSONObject();
coordinates.put("latitude", "YOUR LATITUDE");
coordinates.put("longitude", "YOUR LONGITUDE");
params.putString("coordinates",coordinates.toString());
params.putString("tags", "xxxx");//where xx indicates the User Id
String response = faceBook.request("me/checkins", params, "POST");
Log.d("Response",response);
于 2012-01-12T09:28:54.767 回答
1

可能是 checkinData 格式。尝试:

String checkinData = "{"+
                    "\"message\":\"Test\"," +
                    "\"place\":\"000000000\"," 
                    +   "\"coordinates\":{\"latitude\":\"000000000\", \"longitude\":\"-000000000\"}\"" + "}";
于 2012-01-12T09:31:11.803 回答