简体   繁体   中英

How to check in using facebook android sdk (graph api)

I want to check in using facebook android sdk (graph api),

I am trying this

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);

But its giving me this error

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

is this correct way to check in using facebook graph api

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);

Probaly is the checkinData format. Try:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM