1

According to countless examples and variations of this on the internet, this should work. I have read many similar cases and comments but have not found a clear answer. This does print an access token but fails to authenticate. echo $user always returns 0. I am suspicious there is some configuration issue on http://developers.facebook.com where you get the appID, something in those settings I haven't got quite right. Thanks for any help.

<?  
require 'src/facebook.php';  

 $facebook = new Facebook(array(  

 'appId'  => '{appID}',  
 'secret' => '{secret}',  
 'cookie' =>  'true',
 'baseurl' => 'http://{baseUrl}'  

  ));  

  $user = $facebook->getUser() ;  
  echo $user;  
  print $facebook->getAccessToken();  
?>  
1
  • baseurl should not be http://mizu.net46.net/src/facebook.php change it to http://mizu.net46.net/CallbackFile.php which is either facebookpost.php, facebookpost1.php, facebookpost2.php, facebookpost3.php, facebookpost4.php or facebookpost5.php, remember to change it to that in your App dashboard, too
    – Adam Azad
    Mar 30, 2014 at 8:12

2 Answers 2

0

a snippet of your code,

'baseurl' => 'http://mizu.net46.net/src/facebook.php' 

baseurl must not be facebook.php it should be

'baseurl' => 'http://example.com/myApp/CallbackFile.php'

remember to match baseurl with your website/site URL in your app dashboard

sample of site url setting

duplicates (further reading):

7
  • Adam, thanks, I made some progress fiddling with the formatting, but am still having problems. I must have got the formatting syntax correct now in terms of the AppId and secret because then I see facebook dialogue box pops up asking me to give the app permission. after I check ok, it goes into redirect loop. I run the script again, and there is redirect loop everytime so the handshake or the authentication is not being finished. I can duplicate this same sequence when I create a new app, so my theory is there something that has to be done to fix the redirect loop. Mar 30, 2014 at 14:10
  • "mizu3 will receive the following info: your public profile and friend list. " click cancel or okay. if I click cancel and run the script again I will get the same question again and again, as long as I cancel. once I click OK , and authorize the App then I have redirect loop everytime I run the script from then on. Mar 30, 2014 at 14:36
  • check your error_log, are you running your script on localhost? if yes, that's the reason because Facebook PHP SDK can't be tested an ran on L/M/WAMP
    – Adam Azad
    Mar 30, 2014 at 19:04
  • I am running the script on a web hosting server. (not localhost) Mar 30, 2014 at 21:09
  • maybe you have some code that I could add to my script that might resolve the problem? the only thing thats shows up in the log is when I deliberately change that the key that gets logged. other then that nothing. Mar 30, 2014 at 21:13
0

I fiddled with the settings on the developers.facebook.com long enough I finally found a combination that worked.at this time I can connect and post to my facebook account when I run the app on localhost, why it doesnt work on the webserver is another question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.