Like and comment a post in facebook


#1

Hey guys,

I am trying to implement user like on a particular page post.

I am working on a project where user can like and comment on a page feed post. platform i am using is

cordova version : 3.5
android : 4.4.4

I am using ng-cordova with this plugin ( https://github.com/Wizcorp/phonegap-facebook-plugin). Login is working fine but when i try to implement publish like then it throws an error “Session: an attempt was made to request new permissions for a session that has a pending request”

       $scope.LIkePostFb =  function(post_id){
            $cordovaFacebook.getLoginStatus().then(function(success) {
                if(success.status !== 'connected'){
                 $cordovaFacebook.login(["public_profile", "email", "user_friends"])
                      .then(function(success) {
                          var status = success.status;
                          if(status === 'connected'){
                             $cordovaFacebook.login(["publish_actions"]).then(function(response){
                                console.log(response); 
                             });
                             var response = success.authResponse;
                             storageService.save('LoggedInFb',response);
                          } 
                        });

                    }else{

                      $cordovaFacebook.api(post_id+"/likes", ["publish_actions"])
                            .then(function(success) {
                              // success
                              console.log(success)
                            }, function (error) {
                              // error
                              console.log(error);
                            });
                      
                    }
                   
               });

}

This is how i am trying to get access token for publish. I have shown two method one is using login and other is using api

If user is not logged in , app ask for login and then prompt for publish action( because in android sdk we can’t ask for both read and write together. but it never open that publish permission dialog).

Next method i am trying is using .api(‘post_id/likes’,[‘publish_actions’]) . it return me with error Session: an attempt was made to request new permissions for a session that has a pending request

How can i comment or post a like using android sdk and this plugin? Kindly help.