I m working on an small android project to create facebook events and sharing photos on it . Well I'm succeded in login and logout methods but i m still blocking in the creation of new event, I tried the old method using the:
Bundle params = new Bundle();
params.putString("privacy_type", "OPEN");
params.putString("name", "This is a test event");
params.putString("start_time", "2013-12-02T18:00:00+0530");
params.putString("end_time", "2013-12-02T20:00:00+0530");
params.putString("description", "This is test description yeah?.");
params.putString("location", "Mount Lavinia");
params.putString("privacy_type", "OPEN");
String response = "";
Facebook facebook = new Facebook(APP_ID);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request("me/events", params, "POST",
new RequestListener() {
public void onComplete(String response, Object state) {
try {
Log.i(TAG, "start");
JSONObject event = new JSONObject(response);
Log.i(TAG, response);
String event_id = event.getString("id");
Log.i(TAG, "end");
Log.i(TAG, "Event id => " + event_id);
// Toast.makeText(getApplicationContext(),
// "New Event Created!!",
// Toast.LENGTH_LONG).show();
} catch (Exception e) {
}
}
}, null);
and the new method:
Session session = Session.getActiveSession();
Bundle params = new Bundle();
params.putString("privacy_type", "OPEN");
params.putString("name", "This is a test event");
params.putString("start_time", "2013-12-02T18:00:00+0530");
params.putString("end_time", "2013-12-02T20:00:00+0530");
params.putString("description", "This is test description yeah?.");
params.putString("location", "Mount Lavinia");
new Request(
session,
"me/events",
params,
HttpMethod.POST,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
try {
Log.i(TAG, response.toString());
// Toast.makeText(getApplicationContext(),
// "New Event Created!!",
// Toast.LENGTH_LONG).show();
} catch (Exception e) {
Log.i(TAG, "noresponse");
}
}
}
).executeAsync();
but Im always getting this in the LogCat :
07-04 05:50:48.749: I/MainActivity(3159): {Response: responseCode: 200, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: java.lang.NullPointerException}, isFromCache:false}
See Question&Answers more detail:
os