// User authorized your application if ($_SESSION['state'] == $_GET['state']) { // Get token so you can make API calls getAccessToken(); } else { // CSRF attack? Or did you mix up your states? exit; } } else { if (empty($_SESSION['expires_at']) || time() > $_SESSION['expires_at']) { // Token has expired, clear the state $_SESSION = array(); } if (empty($_SESSION['access_token'])) { // Start authorization process getAuthorizationCode(); } } // Congratulations! You have a valid token. Now fetch your profile $user = fetch('GET', '/v1/people/~:(firstName,lastName)'); print "Hello {$user->firstName} {$user->lastName}."; print "<pre>"; print "Access token " . $_SESSION['access_token']; print "</pre>"; print "<pre>"; var_dump($user); print "</pre>"; print "<pre>"; var_dump($obj); print "</pre>"; exit;
<?php require_once "../common/config.inc.php"; /** * @brief 获取Authorization Code * @param $appid 分配给网站的appid * @param $redirect_uri 成功授权后的回调地址 * @return none 跳转到授权页面 */ function getAuthorizationCode($appkey, $redirect_uri) { $url = "https://api.weibo.com/oauth2/authorize"; //传入参数 $params = array(); $params["client_id"] = $appkey; $params["response_type"] = "code"; $params["redirect_uri"] = $redirect_uri; $url .= "?" . http_build_query($params); header("Location:{$url}"); } getAuthorizationCode($_SESSION["appkey"], $_SESSION["callback"]);
title: \"<span onmouseover=\\\"toolTipTab('$grdTitle', 1);\\\" onmouseout=\\\"toolTipTab('', 0);\\\">$tabTitle</span>\", listeners: { activate: function () { generateGridClassic(\"$processUid\", \"$taskUid\", \"$dynaformUid\"); } } }"; } } if (count($arrayTabItem) > 0) { $urlProxy = '/api/1.0/' . SYS_SYS . '/consolidated/'; $clientId = 'x-pm-local-client'; $client = getClientCredentials($clientId); $authCode = getAuthorizationCode($client); $debug = false; //System::isDebugMode(); $loader = Maveriks\Util\ClassLoader::getInstance(); $loader->add(PATH_TRUNK . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2"); $request = array( 'grant_type' => 'authorization_code', 'code' => $authCode ); $server = array( 'REQUEST_METHOD' => 'POST' ); $headers = array( "PHP_AUTH_USER" => $client['CLIENT_ID'], "PHP_AUTH_PW" => $client['CLIENT_SECRET'],
<?php require_once "../common/config.inc.php"; /** * @brief 获取Authorization Code * @param $appid 申请QQ登录成功后,分配给网站的appid * @param $redirect_uri 成功授权后的回调地址 * @return none 跳转到授权页面 */ function getAuthorizationCode($appid, $redirect_uri) { $url = "https://graph.qq.com/oauth2.0/authorize"; //传入参数 $params = array(); $params["response_type"] = "code"; $params["client_id"] = $appid; $params["redirect_uri"] = $redirect_uri; $url .= "?" . http_build_query($params); header("Location:{$url}"); } getAuthorizationCode($_SESSION["qq_appid"], $_SESSION["qq_callback"]);
<?php require_once "../common/config.inc.php"; /** * @brief 获取Authorization Code * @param $appid 申请QQ登录成功后,分配给网站的appid * @param $redirect_uri 成功授权后的回调地址 * @return none 跳转到授权页面 */ function getAuthorizationCode($appkey, $redirect_uri) { $url = "https://graph.renren.com/oauth/authorize"; //传入参数 $params = array(); $params["response_type"] = "code"; $params["client_id"] = $appkey; $params["redirect_uri"] = $redirect_uri; $params["scope"] = "publish_feed publish_share send_invitation operate_like"; $params["display"] = "page"; $url .= "?" . http_build_query($params); header("Location:{$url}"); } getAuthorizationCode($_SESSION["renren_appkey"], $_SESSION["renren_callback"]);
curl_setopt($ch, CURLINFO_HEADER_OUT, true); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); return $response; } /* * Parse the authorization code, once Spotify has received the OK from the user * This is the first instance where we get the authorization_code, so should only happen once * URL Parameter of ?code= is required */ if (isset($_GET['authorization'])) { getAuthorizationCode($url); } /* * Parse the authorization code, once Spotify has received the OK from the user * This is the first instance where we get the authorization_code, so should only happen once * URL Parameter of ?code= is required */ if (isset($_GET['code'])) { // take our spotify response, and inject it to our localStorage ?> <script type="text/javascript"> var response = <?php echo getToken($_GET['code'], $url); ?> ; var Spotify = JSON.parse( localStorage.getItem('ngStorage-spotify') );
function restart() { $_SESSION = array(); $_SESSION['company'] = $_GET['company']; getAuthorizationCode(); }