php - Facebook Long Token: you must provide or set a default application secret -
im using facebook php sdk exchange short lived token new long lived token. says here, should call url these parameters:
get /oauth/access_token? client_id={app-id} &client_secret={app-secret} &grant_type=client_credentials
if call directly in browser, works ok. curl call , ok. want stay close oficial facebooksdk, in class did method:
public function renewtoken($usershorttoken, $redirecturi = false) { if ($redirecturi !== false) $this->redirecturi = $redirecturi; $this->fbsession = new facebooksession($usershorttoken); $params = '/oauth/access_token?grant_type=fb_exchange_token' . '&client_id=' . $this->appid . '&client_secret=' . $this->appsecret . '&fb_exchange_token=' . $usershorttoken . '&appsecret_proof=' . hash_hmac('sha256', $usershorttoken, $this->appsecret); # appsecret_proof: https://developers.facebook.com/docs/graph-api/securing-requests $this->debug->log('params', $params); try { $request = new facebookrequest($this->fbsession, 'get', $params); $this->debug->log('request', $params); $response = $request->execute(); $this->debug->log('response', $response); $object = $response->getgraphobject(); return $object; } catch (facebookrequestexception $ex) { $this->debug->log('facebookrequestexception', $ex); } catch (\exception $ex) { $this->debug->log('facebookrequestexception', $ex->getmessage()); } return false; }
ps: "$usershorttoken" sent via ajax server, after user has logged in website through facebook javascritp sdk.
so see in console these errors (im using firephp output messages console):
/oauth/access_token?grant_type=fb_exchange_token&client_id=305...57&client_secret=759...6c4&fb_exchange_token=caaev...lr&appsecret_proof=2e...76
you must provide or set default application secret. facebookrequestexception /myserver/.../socialshare/myclass.php:96
i cant understanding message. setted app secret, short token, necessary parameters in url. "appsecret_proof" hash. correct. if copy url , call graph, works , give me long token.
does have idea how stick facebooksdk or should drop task? want in correct possible way.
thank you.
Comments
Post a Comment