Skip to content

Instantly share code, notes, and snippets.

@slav123
Created December 18, 2012 03:49
Show Gist options
  • Save slav123/4324834 to your computer and use it in GitHub Desktop.
Save slav123/4324834 to your computer and use it in GitHub Desktop.
get extended access token
/**
* get extended access token
*
* @param string $token token
*
* @return mixed
*/
public function get_extended_access_token($token)
{
$token_url = "https://graph.facebook.com/oauth/access_token?client_id=" . $this->config->config['facebook']['app_id'] . "&client_secret=" . $this->config->config['facebook']['secret'] . "&grant_type=fb_exchange_token&fb_exchange_token=" . $token;
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_URL, $token_url);
$contents = curl_exec($curl);
$err = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($err) {
log_message('ERROR', print_r($err, 1));
}
curl_close($curl);
$paramsfb = array();
parse_str($contents, $paramsfb);
return $paramsfb['access_token'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment