Topic-icon Delete an App Request

Active Subscriptions:

None
12 years 7 months ago #38303 by Ivan
Delete an App Request was created by Ivan
Hi,

Previously on an earlier version of JFBConnect I was deleting facebook app request like so:

       //Delete Request After Processing
               $apptoken_url = "https://graph.facebook.com/oauth/access_token?" .
                          "client_id=" . $appId .
                          "&client_secret=" . $appSecret .
                          "&grant_type=client_credentials";
               $access_token = file_get_contents($apptoken_url);  //  access token of the app
               $delete_url = "https://graph.facebook.com/".$reqId."_".$fbUserId."?".$access_token."&method=delete";
               $result = file_get_contents($delete_url);  //Delete the request from FB  

I applied this same code and am getting an error Oauth Error ie and the requests are not getting delete. I am getting the access_token so I don't believe file_get_contents has been disabled by FB server. Is there any similar methos with cURL?
The topic has been locked.
Support Specialist
12 years 7 months ago #38316 by alzander
Replied by alzander on topic Delete an App Request
Notifications can be deleted by the Application on behalf of the user. You don't need an OAuth token for the user to do so. If you already have a signature for the Notification to delete, like <requestId>_<fbUserId> (it looks like 123456_2393939), then you should be able to make the following call to delete it:
JFBCFactory::provider('facebook')->api('/123456_2393939', null, false, 'DELETE');
That's how we delete requests that JFBConnect has sent. You can see more about that in the /components/com_jfbconnect/libraries/provider/facebook/request.php file.

If you're using our Requests feature, JFBConnect should be deleting the notification for the user automatically when it's possible. The problem is that Facebook won't provide the user id for the receiver unless they've already approved your app. In that case, you just have to let the request expire after 14 days.

I hope that helps,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 7 months ago #38321 by Ivan
Replied by Ivan on topic Delete an App Request
I need to execute this withing the login.php file

Any insight how to achieve this. I tried putting this directly there but I get an api error.
The topic has been locked.
Support Specialist
12 years 7 months ago #38325 by alzander
Replied by alzander on topic Delete an App Request
Which login.php file, JFBConnect's controllers/login.php file, or something else?

Can you tell me what the API error you're getting is? Knowing that will help us understand what may be going wrong.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 7 months ago #38331 by Ivan
Replied by Ivan on topic Delete an App Request
Yes in ..components/com_jfbconnect/controllers/login.php
The topic has been locked.
Active Subscriptions:

None
12 years 7 months ago - 12 years 7 months ago #38344 by Ivan
Replied by Ivan on topic Delete an App Request
I tried it like so:

       $delete_id = $reqId.'_'.$fbUserId;
               $delsuccess = JFBCFactory::provider('facebook')->api('/'.$delete_id.'', null, false, 'DELETE');
               dump($delsuccess);

I get Facebook API Error: An unknown error has occurred. Null Value. Is the syntax correct?


I also tried this

       $delete_id = $reqId.'_'.$fbUserId;
               $delsuccess = JFBCFactory::provider('facebook')->api('/'.$delete_id, null, false, 'DELETE');
               dump($delsuccess);
Last edit: 12 years 7 months ago by Ivan.
The topic has been locked.
Support Specialist
12 years 7 months ago #38365 by alzander
Replied by alzander on topic Delete an App Request
That syntax looks correct. Can you print out the $delete_id you're using and let me see what it looks like? All I can guess is that it's not correct.

I'm not sure what else would cause that error, or honestly what it even means if the delete_id is correct.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
12 years 7 months ago #38467 by Ivan
Replied by Ivan on topic Delete an App Request
The issue was that the user id was already coming in with the request id. Didn't know facebook made this change.
The topic has been locked.
Support Specialist
12 years 7 months ago #38475 by alzander
Replied by alzander on topic Delete an App Request
Ivan,
Thanks for letting us know what you found. I wasn't aware that they were returning the user id in the string either. We'll investigate that for the v5.3 release. We'd love it if they did, as they hadn't been returning it before unless the user approved the app.. which was pretty stupid.

I'm glad you got it going. If you need anything else, just let us know.

Thanks,
Alex
The topic has been locked.