本文整理汇总了PHP中oauth_session_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP oauth_session_exists函数的具体用法?PHP oauth_session_exists怎么用?PHP oauth_session_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了oauth_session_exists函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify_oauth_session_exists
function verify_oauth_session_exists()
{
if (oauth_session_exists()) {
return;
} else {
header('Location: ' . 'index.php');
}
}
示例2: header
// job 'bookmarked'
header('Location: ' . $_SERVER['PHP_SELF']);
} else {
// problem with 'bookmark'
echo "Error 'bookmarking' job:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
}
} else {
echo "You must supply a job ID to 'bookmark' a job.";
}
break;
case 'unbookmarkJob':
/**
* Handle job 'unbookmarks'.
*/
// check the session
if (!oauth_session_exists()) {
throw new LinkedInException('This script requires session support, which doesn\'t appear to be working correctly.');
}
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$OBJ_linkedin->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
if (!empty($_GET['nJobId'])) {
$response = $OBJ_linkedin->unbookmarkJob($_GET['nJobId']);
if ($response['success'] === TRUE) {
// job 'unbookmarked'
header('Location: ' . $_SERVER['PHP_SELF']);
} else {
// problem with 'unbookmark'
echo "Error 'unbookmarking' job:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
}
} else {
echo "You must supply a job ID to 'unbookmark' a job.";
示例3: linkedin
public function linkedin()
{
try {
$API_CONFIG = array('appKey' => '75wpz389ifrzbq', 'appSecret' => 'ZYEG6gBlFhhUAkfR', 'callbackUrl' => NULL);
define('DEMO_GROUP', '4010474');
define('DEMO_GROUP_NAME', 'Simple LI Demo');
define('PORT_HTTP', '80');
define('PORT_HTTP_SSL', '443');
$_GET['lType'] = isset($_GET['lType']) ? $_GET['lType'] : '';
switch ($_GET['lType']) {
case 'initiate':
if ($_SERVER['HTTPS'] == 'on') {
$protocol = 'https';
} else {
$protocol = 'http';
}
$API_CONFIG['callbackUrl'] = $protocol . '://' . $_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] != PORT_HTTP || $_SERVER['SERVER_PORT'] != PORT_HTTP_SSL ? ':' . $_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF'] . '?' . LINKEDIN::_GET_TYPE . '=initiate&' . LINKEDIN::_GET_RESPONSE . '=1';
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$_GET[LINKEDIN::_GET_RESPONSE] = isset($_GET[LINKEDIN::_GET_RESPONSE]) ? $_GET[LINKEDIN::_GET_RESPONSE] : '';
if (!$_GET[LINKEDIN::_GET_RESPONSE]) {
$response = $OBJ_linkedin->retrieveTokenRequest();
if ($response['success'] === TRUE) {
$_SESSION['oauth']['linkedin']['request'] = $response['linkedin'];
header('Location: ' . LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token']);
} else {
echo "Request token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
}
} else {
$response = $OBJ_linkedin->retrieveTokenAccess($_SESSION['oauth']['linkedin']['request']['oauth_token'], $_SESSION['oauth']['linkedin']['request']['oauth_token_secret'], $_GET['oauth_verifier']);
if ($response['success'] === TRUE) {
$_SESSION['oauth']['linkedin']['access'] = $response['linkedin'];
$_SESSION['oauth']['linkedin']['authorized'] = TRUE;
header('Location: ' . $_SERVER['PHP_SELF']);
} else {
echo "Access token retrieval failed:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
}
}
break;
case 'revoke':
if (!oauth_session_exists()) {
throw new LinkedInException('This script requires session support, which doesn\'t appear to be working correctly.');
}
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$OBJ_linkedin->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
$response = $OBJ_linkedin->revoke();
if ($response['success'] === TRUE) {
session_unset();
$_SESSION = array();
if (session_destroy()) {
header('Location: ' . $_SERVER['PHP_SELF']);
} else {
echo "Error clearing user's session";
}
} else {
echo "Error revoking user's token:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre><br /><br />LINKEDIN OBJ:<br /><br /><pre>" . print_r($OBJ_linkedin, TRUE) . "</pre>";
}
break;
default:
$_SESSION['oauth']['linkedin']['authorized'] = isset($_SESSION['oauth']['linkedin']['authorized']) ? $_SESSION['oauth']['linkedin']['authorized'] : FALSE;
if ($_SESSION['oauth']['linkedin']['authorized'] === TRUE) {
$OBJ_linkedin = new LinkedIn($API_CONFIG);
$OBJ_linkedin->setTokenAccess($_SESSION['oauth']['linkedin']['access']);
$OBJ_linkedin->setResponseFormat(LINKEDIN::_RESPONSE_XML);
$response = $OBJ_linkedin->group(DEMO_GROUP, ':(relation-to-viewer:(membership-state))');
if ($response['success'] === TRUE) {
$result = new SimpleXMLElement($response['linkedin']);
$membership = $result->{'relation-to-viewer'}->{'membership-state'}->code;
$in_demo_group = $membership == 'non-member' || $membership == 'blocked' ? FALSE : TRUE;
} else {
echo "Error retrieving group membership information: <br /><br />RESPONSE:<br /><br /><pre>" . print_r($response, TRUE) . "</pre>";
}
} else {
}
if ($_SESSION['oauth']['linkedin']['authorized'] === TRUE) {
$response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url)');
if ($response['success'] === TRUE) {
$response['linkedin'] = new SimpleXMLElement($response['linkedin']);
echo "<pre>" . print_r($response['linkedin'], TRUE) . "</pre>";
} else {
echo "Error retrieving profile information:<br /><br />RESPONSE:<br /><br /><pre>" . print_r($response) . "</pre>";
}
} else {
}
break;
}
} catch (LinkedInException $e) {
echo $e->getMessage();
}
$this->setErrorMessage('success', 'Registered & Login Successfully');
}