Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
747 views
in Technique[技术] by (71.8m points)

how to create facebook event in an android app?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

https://developers.facebook.com/docs/apps/changelog

Create event Removed - Apps can no longer create events with the API.

This is no longer possible, unfortunately.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...