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();  
?>  
Adam Azad
  • 11,171
  • 5
  • 29
  • 70
  • `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 '14 at 08:12

2 Answers2

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):

Community
  • 1
  • 1
Adam Azad
  • 11,171
  • 5
  • 29
  • 70
  • 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. – user3476896 Mar 30 '14 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. – user3476896 Mar 30 '14 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 '14 at 19:04
  • I am running the script on a web hosting server. (not localhost) – user3476896 Mar 30 '14 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. – user3476896 Mar 30 '14 at 21:13
  • Your app is in sandbox, turn it off so I can debug it :)? – Adam Azad Mar 31 '14 at 12:40
  • there isnt any sandbox feature anymore. I am not familiar with what that translates into their current model. anyway I got it working on localhost. why it the same script gives me an error when I try to run it on the webserver I havent figured out yet......... – user3476896 Apr 01 '14 at 01:11
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.