本文整理汇总了PHP中Instagram::getAccessToken方法的典型用法代码示例。如果您正苦于以下问题:PHP Instagram::getAccessToken方法的具体用法?PHP Instagram::getAccessToken怎么用?PHP Instagram::getAccessToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instagram
的用法示例。
在下文中一共展示了Instagram::getAccessToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nextend_api_auth_flow
function nextend_api_auth_flow()
{
$api_key = NextendRequest::getVar('api_key');
$api_secret = NextendRequest::getVar('api_secret');
$redirect_uri = NextendRequest::getVar('redirect_uri');
if (session_id() == "") {
@session_start();
}
if (!$api_key || !$api_secret || !$redirect_uri) {
$api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null;
$api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null;
$redirect_uri = isset($_SESSION['redirect_uri']) ? $_SESSION['redirect_uri'] : null;
} else {
$_SESSION['api_key'] = $api_key;
$_SESSION['api_secret'] = $api_secret;
$_SESSION['redirect_uri'] = $redirect_uri;
}
if ($api_key && $api_secret) {
require_once dirname(__FILE__) . "/api/Instagram.php";
$config = array('client_id' => $api_key, 'client_secret' => $api_secret, 'redirect_uri' => $redirect_uri, 'grant_type' => 'authorization_code');
$instagram = new Instagram($config);
$accessCode = $instagram->getAccessCode();
if ($accessCode === null) {
$instagram->openAuthorizationUrl();
} else {
$accessToken = $instagram->getAccessToken();
unset($_SESSION['api_key']);
unset($_SESSION['api_secret']);
unset($_SESSION['redirect_uri']);
echo '<script type="text/javascript">';
echo 'window.opener.setToken("' . $accessToken . '");';
echo '</script>';
}
}
}
示例2: array
*
* http://example.com/callback.php must be replaced for REDIRECT-URI
* in the following URI, along with your CLIENT-ID:
* https://instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token
* https://api.instagram.com/oauth/authorize/?client_id=e8d6b06f7550461e897b45b02d84c23e&redirect_uri=http://mauriciocuenca.com/qnktwit/confirm.php&response_type=code
*/
session_start();
require_once 'Instagram.php';
/**
* Configuration params, make sure to write exactly the ones
* instagram provide you at http://instagr.am/developer/
*/
$config = array('client_id' => 'e1d602f8517645749de38593dbf9ad25', 'client_secret' => '63dbfae2a6444956802e269384fc05cc', 'grant_type' => 'authorization_code', 'redirect_uri' => 'http://www.HoopsMap.com/instagram/');
// Instantiate the API handler object
$instagram = new Instagram($config);
$accessToken = $instagram->getAccessToken();
$_SESSION['InstagramAccessToken'] = $accessToken;
$instagram->setAccessToken($_SESSION['InstagramAccessToken']);
$popular = $instagram->getPopularMedia();
print_r($popular);
// After getting the response, let's iterate the payload
$response = json_decode($popular, true);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="styles.css" />
<title>Instagram API PHP Implementation demo // Popular Media</title>
</head>
示例3: testSetAccessToken
/**
* @covers Instaphp\Instagram\Instagram::SetAccessToken
* @todo Implement testSetAccessToken().
*/
public function testSetAccessToken()
{
// Remove the following lines when you implement this test.
$this->object->setAccessToken(TEST_ACCESS_TOKEN);
$this->assertEquals($this->object->getAccessToken(), TEST_ACCESS_TOKEN);
}
示例4: displayEditInstagramSubmit
/**
* displayEditInstagramSubmit
*
* @return void
*/
function displayEditInstagramSubmit()
{
$config = getInstagramConfigData();
if (!empty($config['instagram_client_id']) && !empty($config['instagram_client_secret'])) {
$callbackUrl = getDomainAndDir();
$callbackUrl .= 'settings.php?view=instagram';
$instagram = new Instagram($config['instagram_client_id'], $config['instagram_client_secret'], null);
if (isset($_GET['error']) || isset($_GET['error_reason']) || isset($_GET['error_description'])) {
$this->displayHeader();
echo '
<div class="error-alert">
<p>' . $_GET['error'] . '</p>
<p>' . $_GET['error_reason'] . '</p>
<p>' . $_GET['error_description'] . '</p>
</div>';
$this->displayFooter();
return;
}
$response = $instagram->getAccessToken($_GET['code'], $callbackUrl);
$accessToken = $response->access_token;
$sql = "UPDATE `fcms_user_settings`\n SET `instagram_access_token` = ?\n WHERE `user` = ?";
$params = array($accessToken, $this->fcmsUser->id);
if (!$this->fcmsDatabase->update($sql, $params)) {
$this->displayHeader();
$this->fcmsError->displayError();
$this->displayFooter();
return;
}
} else {
$this->displayHeader();
echo '
<div class="info-alert">
<h2>' . T_('Instagram isn\'t Configured Yet.') . '</h2>
<p>' . T_('Unfortunately, your website administrator has not set up Instagram yet.') . '</p>
</div>';
$this->displayFooter();
return;
}
header("Location: settings.php?view=instagram");
}
示例5: Instagram
<?php
session_start();
require_once 'src/config.php';
require_once 'src/Instagram.php';
$instagram = new Instagram(CLIENT_ID, CLIENT_SECRET, null);
if (isset($_GET['error']) || isset($_GET['error_reason']) || isset($_GET['error_description'])) {
// Throw error message... the user might have pressed Deny.
}
// If there is no error, we should try and grab an access token that we can store in a database or something
// for future use if the user revisits our application
/*
/ Pass the code that you get back from the Authorization call and pass the Redirect URI
/ There is a third parameter "grant_type" which defaults to "authorization_code" (limited by Instagram, currently)
*/
$access_token = $instagram->getAccessToken($_GET['code'], REDIRECT_URI);
$_SESSION['access_token'] = $access_token->access_token;
// Do what you want with the access token, maybe store it in a database?
// Close window or redirect the user back to our index.php so we can pull in some data.
header("Location: index.php");
//exit('<script> window.close(); </script>');