0

I've implemented facebook SDK for android in mycode. I've save user token facebook in server. and use it to invite request to facebook friend. but it show error

API Error code : 110 API Error Descriptions : Invalid user ID Error Message : Missing user cookie (to validate session user)

and this is my code to send request

Session msession;
Bundle params = new Bundle();
params.putString("to", id_friend);
params.putString("message", "Invite your friend");

msession = Session.getActiveSession();

SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss aa");
Date convertedDate = new Date();
try {
     convertedDate = dateFormat.parse(fb_token_expired);
} catch (ParseException e) {

     e.printStackTrace();
}
    final List<String> PERMISSIONS = Arrays.asList("read_requests", "read_mailbox", "manage_notifications");

AccessToken token=AccessToken.createFromExistingAccessToken(fb_token_user, convertedDate, null,AccessTokenSource.CLIENT_TOKEN, PERMISSIONS);

 msession = Session.openActiveSessionWithAccessToken(c, token, new StatusCallback(){
 @Override
 public void call(Session aSession, SessionState aState, Exception aException) {
            if (aException != null) {

            }


        }
   });

if(msession.isOpened()){
        requestsDialog = (new WebDialog.RequestsDialogBuilder(this,msession,params))
                  .setOnCompleteListener(new OnCompleteListener() {

                        @Override
                        public void onComplete(Bundle values,
                            FacebookException error) {
                            if (error != null) {
                                if (error instanceof FacebookOperationCanceledException) {

                                        Toast.makeText(getApplicationContext(), "Request cancelled", Toast.LENGTH_SHORT).show();
                                } else {
                                    Toast.makeText(getApplicationContext(), 
                                        "Network Error", 
                                        Toast.LENGTH_SHORT).show();
                                }
                            } else {
                                final String requestId = values.getString("request");
                                if (requestId != null) {


                                    Log.e("success", "success");


                                } else {
                                    Toast.makeText(getApplicationContext(), "Request cancelled", Toast.LENGTH_SHORT).show();
                                }
                            }   
                        }



                    })
                    .build();
            requestsDialog.show();
        }

any solution?? thanks :)

4

0 回答 0