3

I have defined the Deauthorize Callback URL in the application settings. And according to the facebook documentation whenever a user removes an application, a HTTP POST request is sent containing signed_request which contains user id.

https://developers.facebook.com/docs/authentication/

I have tried doing the same but for some odd reason i believe that the URL specified never gets pinged on removing because i tried adding some random UPDATE query and it never got triggered.

 $signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2); 
$data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
$user_id = $data['user_id'];
$query = mysql_query("INSERT INTO `removeapp` (uid) VALUES ('$user_id')");
Saad Bashir
  • 4,341
  • 8
  • 30
  • 60
  • you are actually opening a connection to your DB above this code, right? – ifaour Mar 14 '12 at 08:34
  • Yes i have already done that by including a connection file which i am doing on the other pages too! – Saad Bashir Mar 14 '12 at 09:56
  • try logging the info instead of making MySQL query: `error_log('POST Request = ' . print_r($data, true), 3, './deauthorize.log');` it's working just fine for me – ifaour Mar 14 '12 at 10:04
  • I am sorry i didn't quite get how to use it? should i replace my current code and paste the one you just wrote as it is? – Saad Bashir Mar 14 '12 at 10:18
  • nevermind i think i get what this will do.. it will save the data in error_log file right? :D – Saad Bashir Mar 14 '12 at 10:19
  • yes, just create the log file, then uninstall your app to see the result. – ifaour Mar 14 '12 at 10:20
  • i did that but it didn't populate anything in the error_log and it didn't make the deauthorize.log file either ` $signed_request = $_REQUEST["signed_request"]; list($encoded_sig, $payload) = explode('.', $signed_request, 2); $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true); error_log('POST Request = ' . print_r($data, true), 3, './deauthorize.log'); ` – Saad Bashir Mar 14 '12 at 10:23
  • to ensure i have placed the right url in the app settings i ran the file directly in the browser after copying it from there and it created the deauthorize.log file – Saad Bashir Mar 14 '12 at 10:28
  • do you have other includes? ...etc? try running the script on the browser directly with ALL errors set to show (warning, notices...etc) to see if there's something else affecting the script. – ifaour Mar 14 '12 at 11:37
  • There aren't any includes or anything.. i am pasting the code i tried which didn't yield any results. This is the only content in the file – Saad Bashir Mar 14 '12 at 11:47
  • Changing the url from https to http made it work fine! Thanks alot for the help @ifaour – Saad Bashir Mar 14 '12 at 18:12
  • I had the same problem with https, and I finally figured out *why* today: http://stackoverflow.com/questions/10369169/facebook-deauthorize-callback-over-https/20024430#20024430 Should this question or my original one be closed as a duplicate? I've already answered my own at the link provided. – CasaDeRobison Nov 16 '13 at 22:16

1 Answers1

0

try with this

https://developers.facebook.com/tools/debug/

see facebook's servers are able to reach your callback URL.

Ganpat Kaliya
  • 888
  • 2
  • 9
  • 16