1

I have no idea why working with this sdk is so complex :(

In my application when user lunches the app for first time, then I get token and user Id.

public void OnFacebookLoginButtonClicked() {
        // start Facebook Login
        Session.openActiveSession(SplashScreen.this, true, new Session.StatusCallback() {
            // callback when session changes state
            @Override
            public void call(final Session session, SessionState state, Exception exception) {
                if (session.isOpened()) {
                    // make request to the /me API
                    Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

                        // callback after Graph API response with user object
                        @Override
                        public void onCompleted(GraphUser user, Response response) {
                            if (user != null) {
                                Log.i(TAG, "User name: " + user.getName() + "!, Login successfully :)");
                                Log.i(TAG, "User id: " + user.getId());
                                Log.i(TAG, "Access token is: " + session.getAccessToken());
                                Log.i(TAG, "Application id: " + session.getApplicationId());

                                SpStorage.setToken(SplashScreen.this, session.getAccessToken());
                                SpStorage.setFacebookUserId(SplashScreen.this, user.getId());

                                registerUser();
                            }
                        }
                    });
                }
            }
        });
    }

It works fine without problem.

Somewhere else in my application (In a fragment), I need to share something on wall of user.

private void shareOnFacebook() {
        final Bundle params = new Bundle();

        params.putByteArray("message", "Test".getBytes());
        params.putByteArray("name", "American Virgin".getBytes());
        params.putByteArray("link", "http://bit.ly/12345".getBytes());
        params.putByteArray("description", "A Freshman College Girl on a scholarship from an ...".getBytes());
        params.putByteArray("picture", "http://xxx/MOV1026.jpg".getBytes());

        final Request postToWall = Request.newRestRequest(Session.getActiveSession(),
                "https://graph.facebook.com/<USER_ID>/feed", params, HttpMethod.POST);
        postToWall.setCallback( new Request.Callback() {
            @Override
            public void onCompleted(Response response) {
                Log.i(TAG, response.toString());

            }
        });
        Request.executeBatchAsync(postToWall);
    }

However, my response is:

04-12 16:25:29.898: I/VenueFragment(29624): {Response: responseCode: 200, graphObject: null, error: {HttpStatus: 200, errorCode: 101, errorType: null, errorMessage: Invalid application ID.}, isFromCache:false}

Since, warning is saying Application id is not valid I tried following code but result was same.

final Request postToWall = Request.newRestRequest(Session.getActiveSession(),
                    "https://graph.facebook.com/APPLICATION_ID/feed", params, HttpMethod.POST);

What do you think? Is it because of permission? If you know any weblog that explain same scenario please tell it to me. I read all content of Facebook samples but all of them was base on Facebook login button. Please forget Facebook samples.

I have no idea why this simple thing is becoming so complex for me :(((((

4

0 回答 0