Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 287
Adil Bhatty Avatar asked Jan 12 '12 09:01

Adil Bhatty


2 Answers

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);
like image 81
Venky Avatar answered Sep 28 '22 18:09

Venky


Probaly is the checkinData format. Try:

String checkinData = "{"+
                    "\"message\":\"Test\"," +
                    "\"place\":\"000000000\"," 
                    +   "\"coordinates\":{\"latitude\":\"000000000\", \"longitude\":\"-000000000\"}\"" + "}";
like image 44
djserva Avatar answered Sep 28 '22 17:09

djserva