本文整理汇总了PHP中Rest::http_request方法的典型用法代码示例。如果您正苦于以下问题:PHP Rest::http_request方法的具体用法?PHP Rest::http_request怎么用?PHP Rest::http_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rest
的用法示例。
在下文中一共展示了Rest::http_request方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getToken
/**
* Get an access token, either from the cookies or from instagram
* TODO: Fallback if need to login again!
*/
private function getToken() {
$access_token = $this->session->userdata('access_token');
if (!$access_token) {
if (!isset($_GET['code'])) {
show_error('You are not signed in. Please first sign in. (im.php-176). <a href="' . $this->config->item('base_url') . '">Home</a>');
}
$this->load->library('rest');
$request = 'https://api.instagram.com/oauth/access_token';
$headers = array(
'client_id' => $this->config->item('config_id'),
'client-secret' => $this->config->item('client_secret'),
'code' => $_GET['code'],
'redirect_uri' => $this->config->item('redirect_uri'),
);
$data = 'client_id=' . $this->config->item('client_id') . '&client_secret=' . $this->config->item('client_secret') . '&code=' . $_GET['code'] . '&redirect_uri=' . $this->config->item('redirect_uri') . '&grant_type=authorization_code';
$result = Rest::http_request($request, $headers, 'POST', $data);
if ($result->code != 200) {
show_error($result->error . ' (im.php 190)');
}
$result = json_decode($result->data);
$access_token = $result->access_token;
}
$this->session->set_userdata(array('access_token' => $access_token));
return $access_token;
}