Advertisement
DenChu

Изменение в формате возврата токена FB

Apr 7th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1.     public function getAccessToken( $code )
  2.     {
  3.         $url = self::ACCESS_TOKEN_URL . '?client_id=' . $this->_appId . '&redirect_uri=' . urlencode( $this->_callBackUrl ) . '&client_secret=' . $this->_appSecret . '&code=' . rawurlencode( $code );
  4.        
  5.         /* Send it and hope to receive access_token=blah */
  6.         $result = $this->_send( $url, 'GET' );
  7.        
  8.         $params = null;
  9.        
  10.         parse_str($result, $params);
  11.        
  12.  
  13.         if ( $params['access_token'] )
  14.         {
  15.             return $params['access_token'];
  16.         }
  17.         else
  18.         {
  19.             /* Likely to be an error in json */
  20.             $params = json_decode( $result );
  21.             return $params->access_token;
  22.         }
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement