oauth - Facebook Graph API problem -
i've got trouble facebook authentication. when i'm logged, function getuser() returns 0
here's code :
$fb_params = array( 'appid' => app_id, 'secret' => secret_id ); $fb = new facebook($fb_params); echo $fb->getuser(); // uid someone's got idea?
ps : 'i can no long access $fb->api('/me'), says requires access_token, think it's linked authentication issue...'
thanks
you not authenticating user, application. result, facebook api can't show /me page or respond getuser() call since doesn't know user trying access api on behalf of (ie. "who /me?"). able access publically-accessible information.
you need user authenticate application through oauth2, store access_token returned, , include in future calls (eg. wirqjcey1.3600.1309525200.0-509450630|ed6sar">https://graph.facebook.com/me?access_token=2227470867|2.aqb-_wirqjcey1.3600.1309525200.0-509450630|ed6sar...).
to using php sdk can do
$loginurl = $fb->getloginurl(); echo "<a href='$loginurl'>login facebook</a>"; clicking link , having user authenticate store access_token $_session, , when hit refresh "new facebook( $fb_params );" constructor pick out access token $_session , use future calls, calls $fb->getuser(); return correctly.
there's functioning example in examples folder of sdk, here: https://github.com/facebook/php-sdk. can use try calls while authenticated application (public data access only), , user.
Comments
Post a Comment