当前位置: 首页>>代码示例>>PHP>>正文


PHP OAuth::enableDebug方法代码示例

本文整理汇总了PHP中OAuth::enableDebug方法的典型用法代码示例。如果您正苦于以下问题:PHP OAuth::enableDebug方法的具体用法?PHP OAuth::enableDebug怎么用?PHP OAuth::enableDebug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OAuth的用法示例。


在下文中一共展示了OAuth::enableDebug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCallback

 public function actionCallback($oauth_token)
 {
     try {
         $login_secret = $this->getSession('oauth')->login_secret;
         if (!$oauth_token) {
             echo "Error! There is no OAuth token!";
             exit;
         }
         if (!$login_secret) {
             echo "Error! There is no OAuth secret!";
             exit;
         }
         $this->oauth->enableDebug();
         $this->oauth->setToken($oauth_token, $login_secret);
         $access_token_info = $this->oauth->getAccessToken(self::ACCESS_TOKEN_URL);
         $this->getSession('oauth')->login_secret = false;
         $this->getSession('oauth')->token = $access_token_info['oauth_token'];
         $this->getSession('oauth')->secret = $access_token_info['oauth_token_secret'];
         $this->getUserDetailsAndLoginUser();
     } catch (OAuthException $E) {
         Debugger::log($E);
         //zalogujeme for sichr
         echo "OAuth login failed. Please, contact administrator.";
         $this->terminate();
     }
 }
开发者ID:osmcz,项目名称:website,代码行数:26,代码来源:OauthPresenter.php

示例2: setOAuth

function setOAuth()
{
    //  pecl_oauth
    $oauth = new OAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_FORM);
    $oauth->enableDebug();
    try {
        if (isset($_GET['oauth_token'], $_SESSION['oauth_token_secret'])) {
            $oauth->setToken($_GET['oauth_token'], $_SESSION['oauth_token_secret']);
            $accessToken = $oauth->getAccessToken(TWITTER_ACCESS_URL);
            $_SESSION['oauth_token'] = $accessToken['oauth_token'];
            $_SESSION['oauth_token_secret'] = $accessToken['oauth_token_secret'];
            $response = $oauth->getLastResponse();
            parse_str($response, $get);
            if (!isset($get['user_id'])) {
                throw new Exception('Authentication failed.');
            }
        } else {
            $requestToken = $oauth->getRequestToken(TWITTER_REQUEST_URL);
            $_SESSION['oauth_token_secret'] = $requestToken['oauth_token_secret'];
            header('Location: ' . TWITTER_AUTHORIZE_URL . '?oauth_token=' . $requestToken['oauth_token']);
            die;
        }
    } catch (Exception $e) {
        var_dump($oauth->debugInfo);
        die($e->getMessage());
    }
}
开发者ID:napthats,项目名称:rtter_js_php,代码行数:27,代码来源:connect.php

示例3: call

 function call($command)
 {
     session_start();
     if (!isset($_GET['oauth_token']) && $_SESSION['state'] == 1) {
         $_SESSION['state'] = 0;
     }
     try {
         $oauth = new \OAuth($this->consumer_key, $this->consumer_secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
         $oauth->enableDebug();
         if (!isset($_GET['oauth_token']) && !$_SESSION['state']) {
             $request_token_info = $oauth->getRequestToken($this->request_url);
             $_SESSION['secret'] = $request_token_info['oauth_token_secret'];
             $_SESSION['state'] = 1;
             header('Location: ' . $this->authorize_url . '?oauth_token=' . $request_token_info['oauth_token']);
             exit;
         } else {
             if ($_SESSION['state'] == 1) {
                 $oauth->setToken($_GET['oauth_token'], $_SESSION['secret']);
                 $access_token_info = $oauth->getAccessToken($this->access_token_url);
                 error_log("acc token info " . $access_token_info, 1, "dustinmoorman@gmail.com");
                 $_SESSION['state'] = 2;
                 $_SESSION['token'] = $access_token_info['oauth_token'];
                 $_SESSION['secret'] = $access_token_info['oauth_token_secret'];
             }
         }
         $oauth->setToken($_SESSION['token'], $_SESSION['secret']);
         $oauth->fetch("{$this->api_url}{$command}");
         $json = json_decode($oauth->getLastResponse());
     } catch (\OAuthException $E) {
         return $E->lastResponse;
     }
     return $json;
 }
开发者ID:rocketcloudsolutions,项目名称:rcsoauth,代码行数:33,代码来源:Base.php

示例4: authorize

 function authorize()
 {
     $oauth = new OAuth(Config::get('TWITTER_CONSUMER_KEY'), Config::get('TWITTER_CONSUMER_SECRET'), OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
     $oauth->enableDebug();
     try {
         $request_token = $oauth->getRequestToken($this->request_token_url);
     } catch (OAuthException $e) {
         debug($oauth->debugInfo);
     }
     $url = $this->authorize_url . '?' . http_build_query(array('oauth_token' => $request_token['oauth_token'], 'callback_url'));
     print 'Authorize: ' . $url . "\n";
     system(sprintf('open %s', escapeshellarg($url)));
     fwrite(STDOUT, "Enter the PIN: ");
     $verifier = trim(fgets(STDIN));
     //$oauth->setToken($token, $request_token['oauth_token_secret']);
     //$access_token = $oauth->getAccessToken($this->access_token_url);
     $oauth->setToken($request_token['oauth_token'], $request_token['oauth_token_secret']);
     try {
         $access_token = $oauth->getAccessToken($this->access_token_url, NULL, $verifier);
     } catch (OAuthException $e) {
         debug($oauth->debugInfo);
     }
     printf("'TWITTER_TOKEN' => '%s',\n'TWITTER_TOKEN_SECRET' => '%s',\n", $access_token['oauth_token'], $access_token['oauth_token_secret']);
     exit;
 }
开发者ID:hubgit,项目名称:libapi,代码行数:25,代码来源:Twitter.php

示例5: REST_Request

 public function REST_Request($callbackUrl, $url, $method, $data = array())
 {
     /**
      * Example of simple product POST using Admin account via Magento REST API. OAuth authorization is used
      */
     $callbackUrl = $callbackUrl;
     $temporaryCredentialsRequestUrl = $this->conf['magento_host'] . "/oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
     $adminAuthorizationUrl = $this->conf['magento_host'] . '/admin/oauth_authorize';
     $accessTokenRequestUrl = $this->conf['magento_host'] . '/oauth/token';
     $apiUrl = $this->conf['magento_host'] . '/api/rest';
     $consumerKey = $this->conf['magentosoap_consumerKey'];
     $consumerSecret = $this->conf['magentosoap_consumerSecret'];
     $AccessToken = $this->conf["magentosoap_AccessToken"];
     $AccessSecret = $this->conf["magentosoap_AccessSecret"];
     try {
         //$_SESSION['state'] = 2;
         $authType = 2 == 2 ? OAUTH_AUTH_TYPE_AUTHORIZATION : OAUTH_AUTH_TYPE_URI;
         $oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);
         $oauthClient->enableDebug();
         $oauthClient->disableSSLChecks();
         $oauthClient->setToken($AccessToken, $AccessSecret);
         $resourceUrl = $apiUrl . $url;
         $oauthClient->fetch($resourceUrl, $data, strtoupper($method), array("Content-Type" => "application/json", "Accept" => "*/*"));
         //$oauthClient->fetch($resourceUrl);
         $ret = json_decode($oauthClient->getLastResponse());
         $ret = array("error" => 0, "data" => $ret);
         return $ret;
     } catch (OAuthException $e) {
         $ret = array("error" => 1, "message" => "Checking quantity failed");
         return $ret;
     }
 }
开发者ID:tedicela,项目名称:phpmagentoapi,代码行数:32,代码来源:MagentoApi.lib.php

示例6: getTwitterFriendIds

function getTwitterFriendIds($user)
{
    $cacheExpire = 24 * 60 * 60;
    $POD = $user->POD;
    $key = $POD->libOptions('twitter_api');
    $secret = $POD->libOptions('twitter_secret');
    $friends = array();
    if ($user->get('twitter_token')) {
        if ($user->get('twitter_list') != '' && time() - $user->get('twitter_list_generated') < $cacheExpire) {
            $twoots = json_decode($user->get('twitter_list'));
            foreach ($twoots as $f) {
                $friends[] = $f;
            }
        } else {
            try {
                $oauth = new OAuth($key, $secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
                $oauth->enableDebug();
                // This will generate debug output in your error_log
                $oauth->setToken($user->get('twitter_token'), $user->get('twitter_secret'));
                $oauth->fetch('https://twitter.com/friends/ids.json?cursor=-1&user_id=' . $user->get('twitter_id'));
                $json = json_decode($oauth->getLastResponse());
            } catch (Exception $e) {
            }
            // contains the first 5000 twitter friends
            foreach ($json->ids as $id) {
                $friends[] = $id;
            }
            $user->addMeta('twitter_list', json_encode($friends));
            $user->addMeta('twitter_list_generated', time());
        }
    }
    return $friends;
}
开发者ID:RichieDupes,项目名称:PeoplePods,代码行数:33,代码来源:methods.php

示例7: GetReportsResponse

 public function GetReportsResponse($requestParameters, $requestBody, $oauthRequestUri)
 {
     $this->context->IppConfiguration->Logger->CustomLogger->Log(TraceLevel::Info, "Called PrepareRequest method");
     // This step is required since the configuration settings might have been changed.
     $this->RequestCompressor = CoreHelper::GetCompressor($this->context, true);
     $this->ResponseCompressor = CoreHelper::GetCompressor($this->context, false);
     $this->RequestSerializer = CoreHelper::GetSerializer($this->context, true);
     $this->ResponseSerializer = CoreHelper::GetSerializer($this->context, false);
     // Determine dest URI
     $requestUri = '';
     if ($requestParameters->ApiName) {
         // Example: "https://appcenter.intuit.com/api/v1/Account/AppMenu"
         $requestUri = $this->context->baseserviceURL . $requestParameters->ApiName;
     } else {
         if ($oauthRequestUri) {
             // Prepare the request Uri from base Uri and resource Uri.
             $requestUri = $oauthRequestUri;
         } else {
             if ($requestParameters->ResourceUri) {
                 $requestUri = $this->context->baseserviceURL . $requestParameters->ResourceUri;
             } else {
             }
         }
     }
     $oauth = new OAuth($this->context->requestValidator->ConsumerKey, $this->context->requestValidator->ConsumerSecret);
     $oauth->setToken($this->context->requestValidator->AccessToken, $this->context->requestValidator->AccessTokenSecret);
     $oauth->enableDebug();
     $oauth->setAuthType(OAUTH_AUTH_TYPE_AUTHORIZATION);
     $oauth->disableSSLChecks();
     $httpHeaders = array();
     if ('QBO' == $this->context->serviceType || 'QBD' == $this->context->serviceType) {
         // IDS call
         $httpHeaders = array('accept' => 'application/json');
         // Log Request Body to a file
         $this->RequestLogging->LogPlatformRequests($requestBody, $requestUri, $httpHeaders, TRUE);
         if ($this->ResponseCompressor) {
             $this->ResponseCompressor->PrepareDecompress($httpHeaders);
         }
     } else {
         // IPP call
         $httpHeaders = array('accept' => 'application/json');
     }
     try {
         $OauthMethod = OAUTH_HTTP_METHOD_GET;
         $oauth->fetch($requestUri, $requestBody, $OauthMethod, $httpHeaders);
     } catch (OAuthException $e) {
         //echo "ERROR:\n";
         //print_r($e->getMessage()) . "\n";
         list($response_code, $response_xml, $response_headers) = $this->GetOAuthResponseHeaders($oauth);
         $this->RequestLogging->LogPlatformRequests($response_xml, $requestUri, $response_headers, FALSE);
         return FALSE;
     }
     list($response_code, $response_xml, $response_headers) = $this->GetOAuthResponseHeaders($oauth);
     // Log Request Body to a file
     $this->RequestLogging->LogPlatformRequests($response_xml, $requestUri, $response_headers, FALSE);
     return array($response_code, $response_xml);
 }
开发者ID:andrewhook,项目名称:SampleApp-PHP-for-OpenId-OAuth-V3APICalls,代码行数:57,代码来源:RestServiceHandler.php

示例8: getCategories

 private function getCategories()
 {
     $brands = Brands::all();
     return $brands;
     $consumer_key = 'b64350b6b45c8fed49aa9983bf197844';
     $consumer_secret = '85b3ce2964a63c8fb07d868a58f13b69';
     $oauth_token = 'd5608ad8dbd007c0d5cd10688e7d428d';
     $oauth_secret = '9f11ac72c96ffd96a00ee58cf67b2d2a';
     $client = new \OAuth($consumer_key, $consumer_secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
     $client->enableDebug();
     $client->setToken($oauth_token, $oauth_secret);
     try {
         $client->fetch('http://local.giftbig.com/rest/catalog', '', OAUTH_HTTP_METHOD_GET, ['Content-Type' => 'application/json', 'Accept' => '*/*']);
         $result = $client->getLastResponse();
         $result = json_decode($result);
         return $result->_embedded->products;
     } catch (\Exception $e) {
         return [];
     }
 }
开发者ID:spesalvi,项目名称:market-demo,代码行数:20,代码来源:HomeController.php

示例9: makeRequestAndPrintResponse

 private static function makeRequestAndPrintResponse($method, $params, $signature_method = OAUTH_SIG_METHOD_HMACSHA1)
 {
     $oauth = new OAuth(Settings::$USOSAPI_CONSUMER_KEY, Settings::$USOSAPI_CONSUMER_SECRET, $signature_method, OAUTH_AUTH_TYPE_URI);
     if ($signature_method == OAUTH_SIG_METHOD_PLAINTEXT) {
         $oauth->setRequestEngine(OAUTH_REQENGINE_CURL);
     }
     if (Settings::$DEBUG) {
         $oauth->enableDebug();
     }
     $url = Settings::$USOSAPI_BASE_URL . $method;
     try {
         $oauth->fetch($url, $params, OAUTH_HTTP_METHOD_POST);
     } catch (OAuthException $E) {
         /* Ignored on purpose. $response_info will be filled either way. */
     }
     $response_info = $oauth->getLastResponseInfo();
     header("HTTP/1.0 {$response_info["http_code"]}");
     header("Content-Type: {$response_info["content_type"]}");
     print $oauth->getLastResponse();
 }
开发者ID:JulianVolodia,项目名称:jquery-usos,代码行数:20,代码来源:usosapiProxy.php

示例10: _oauthReq

 private function _oauthReq($url, $content = null, $reqType = null, $nonce = null, $timestamp = null)
 {
     try {
         $oauth = new OAuth($this->clientKey, $this->clientSecret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
         $oauth->enableDebug();
         $oauth->setToken($this->tokenKey, $this->tokenSecret);
         if (!is_null($nonce)) {
             $oauth->setNonce($nonce);
         }
         if (!is_null($timestamp)) {
             $oauth->setTimestamp($timestamp);
         }
         if (is_null($reqType)) {
             $reqType = OAUTH_HTTP_METHOD_GET;
         }
         $oauth->fetch("{$url}", $content, $reqType);
         $ret = $oauth->getLastResponse();
         return $ret;
     } catch (OAuthException $e) {
         //return $e->lastResponse;
         return $e;
     }
 }
开发者ID:eecian,项目名称:Team08-iPeer,代码行数:23,代码来源:v1_controller.test.php

示例11: OAuth

 function __construct()
 {
     // In state=1 the next request should include an oauth_token.
     // If it doesn't go back to 0
     if (!isset($_GET['oauth_token']) && $_SESSION['state'] == 1) {
         $_SESSION['state'] = 0;
     }
     try {
         $oauth = new OAuth(self::CONSKEY, self::CONSSEC, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
         $oauth->enableDebug();
         if ($_SESSION['state'] != 2) {
             if (!isset($_GET['oauth_token']) && !$_SESSION['state']) {
                 $queryString = http_build_query(array('scope' => 'https://www.googleapis.com/auth/latitude', 'oauth_callback' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));
                 $requestToken = $oauth->getRequestToken(self::REQ_URL . '?' . $queryString);
                 $_SESSION['secret'] = $requestToken['oauth_token_secret'];
                 $_SESSION['state'] = 1;
                 $queryString = http_build_query(array('oauth_token' => $requestToken['oauth_token'], 'domain' => $_SERVER['HTTP_HOST'], 'location' => 'all', 'granularity' => 'best'));
                 header('Location: ' . self::AUTH_URL . '?' . $queryString);
                 exit;
             } else {
                 if ($_SESSION['state'] == 1) {
                     $oauth->setToken($_GET['oauth_token'], $_SESSION['secret']);
                     $accessToken = $oauth->getAccessToken(self::ACC_URL);
                     $_SESSION['state'] = 2;
                     $_SESSION['token'] = $accessToken['oauth_token'];
                     $_SESSION['secret'] = $accessToken['oauth_token_secret'];
                 }
             }
         }
         $oauth->setToken($_SESSION['token'], $_SESSION['secret']);
     } catch (OAuthException $e) {
         trigger_error("OAuth fail: " . print_r($e, true));
         print "Oh dear, something failed during the OAuth handshake with google!";
         exit;
     }
     $this->oauth = $oauth;
 }
开发者ID:Jonty,项目名称:ListeningLocations,代码行数:37,代码来源:oauthfetcher.class.php

示例12: array

 function get_data($url, $params = array(), $format = 'json', $http = array(), $cache = TRUE)
 {
     unset($this->response, $this->data, $this->xpath);
     if (!isset($http['method'])) {
         $http['method'] = 'GET';
     }
     if ($cache && $this->cache) {
         // can set either of these to FALSE to disable the cache
         if ($http['method'] === 'GET') {
             // only use the cache for GET requests (TODO: allow caching of some POST requests?)
             return $this->get_cached_data($url, $params, $format, $http);
         }
     }
     // FIXME: is this a good idea?
     if ($http['method'] === 'POST' && empty($http['content']) && !empty($params)) {
         $http['content'] = http_build_query($params);
         $params = array();
     }
     if (!empty($params)) {
         ksort($params);
         $url .= '?' . http_build_query($params);
     }
     if (isset($http['file'])) {
         $http['content'] = file_get_contents($http['file']);
     }
     // TODO: allow setting default HTTP headers in Config.php
     if (!isset($http['header']) || !preg_match('/Accept: /', $http['header'])) {
         $http['header'] .= (empty($http['header']) ? '' : "\n") . $this->accept_header($format);
     }
     $http['header'] .= (empty($http['header']) ? '' : "\n") . "Connection: close";
     //debug($http);
     //$http['header'] = '';
     $context = empty($http) ? NULL : stream_context_create(array('http' => $http));
     if (!empty($this->oauth)) {
         $oauth = new OAuth($this->oauth['consumer_key'], $this->oauth['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
         $oauth->enableDebug();
         $oauth->setToken($this->oauth['token'], $this->oauth['secret']);
         try {
             $headers = explode("\n", $http['header']);
             $http['header'] = array();
             foreach ($headers as $value) {
                 if (preg_match('/^\\s*(.+?):\\s*(.+)/', $value, $matches)) {
                     $http['header'][$matches[1]] = trim($matches[2]);
                 }
             }
             $oauth->fetch($url, $http['content'], constant('OAUTH_HTTP_METHOD_' . $http['method']), $http['header']);
             $this->response = $oauth->getLastResponse();
             //debug($this->response);
             $info = $oauth->getLastResponseInfo();
             //debug($info);
             $this->http_response_header = explode("\n", $info['headers_recv']);
             //debug($this->http_response_header);
         } catch (OAuthException $e) {
             debug($oauth->debugInfo);
         }
     } else {
         debug_log('Sending request to ' . $url);
         debug('Sending request to ' . $url);
         //debug(array($url, $http));
         $this->response = file_get_contents($url, false, $context);
         $this->http_response_header = $http_response_header;
     }
     //debug($this->http_response_header);
     $this->parse_http_response_header();
     $this->parse_effective_url($url);
     debug('Received response from ' . $this->http_effective_url);
     debug_log('Received response from ' . $this->http_effective_url);
     //debug_log($this->response);
     if ($this->response !== false) {
         try {
             $this->data = $this->format_data($format);
             $this->validate_data($format);
         } catch (DataException $e) {
             $e->errorMessage();
         } catch (Exception $e) {
             debug($e->getMessage());
         }
     }
     return $this->data;
 }
开发者ID:hubgit,项目名称:libapi,代码行数:80,代码来源:API.php

示例13: OAuth

            print " Secret: {$access_secret}\n";
            print " Session Handle: {$access_session}\n\n";
        } else {
            $access_token = NULL;
            $access_secret = NULL;
            $access_session = NULL;
            print "Unable to refresh access token, will need to request a new one.\n";
        }
    }
}
// 3. If none of that worked, send the user to get a new token
if (!$access_token) {
    print 'no access token ******************';
    print "Better try to get a new access token.\n";
    $o = new OAuth($consumer_key, $consumer_secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
    $o->enableDebug();
    $request_token = NULL;
    try {
        $response = $o->getRequestToken("https://api.login.yahoo.com/oauth/v2/get_request_token", 'oob');
        print '<br />';
        print 'response<br /><br />';
        var_dump($response);
        print '<br /><br />';
        print '<br />';
        $request_token = $response['oauth_token'];
        $request_secret = $response['oauth_token_secret'];
        print "Hey! Go to this URL and tell us the verifier you get at the end.\n";
        print ' ' . $response['xoauth_request_auth_url'] . "\n";
    } catch (OAuthException $e) {
        print $e->getMessage() . "\n";
    }
开发者ID:russelldavidson,项目名称:fantasy-football,代码行数:31,代码来源:index.php

示例14: oauth

 function oauth()
 {
     $oauth = new OAuth($this->config['consumer_key'], $this->config['consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);
     $oauth->enableDebug();
     return $oauth;
 }
开发者ID:hubgit,项目名称:mendeley-docnotes,代码行数:6,代码来源:Mendeley.php

示例15: OAuth

    /**
     * Create the event RSVP popup
     */
    function meetup_event_popup()
    {
        session_start();
        $header = '<html dir="ltr" lang="en-US">
			<head>
				<meta charset="UTF-8" />
				<meta name="viewport" content="width=device-width" />
				<title>RSVP to a Meetup</title>
				<link rel="stylesheet" type="text/css" media="all" href="' . get_bloginfo('stylesheet_url') . '" />
				<style>
					.button {
						padding:3%;
						color:white;
						background-color:#B03C2D;
						border-radius:3px;
						display:block;
						font-weight:bold;
						width:40%;
						float:left;
						text-align:center;
					}
					.button.no {
						margin-left:8%;
					}
				</style>
			</head>
			<body>
				<div id="page" class="hfeed meetup event" style="padding:15px;">';
        if (array_key_exists('event', $_GET)) {
            $_SESSION['event'] = $_GET['event'];
        }
        if (!array_key_exists('state', $_SESSION)) {
            $_SESSION['state'] = 0;
        }
        // In state=1 the next request should include an oauth_token.
        // If it doesn't go back to 0
        if (!isset($_GET['oauth_token']) && $_SESSION['state'] == 1) {
            $_SESSION['state'] = 0;
        }
        try {
            $oauth = new OAuth($this->key, $this->secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
            $oauth->enableDebug();
            if (!isset($_GET['oauth_token']) && !$_SESSION['state']) {
                $request_token_info = $oauth->getRequestToken($this->req_url);
                $_SESSION['secret'] = $request_token_info['oauth_token_secret'];
                $_SESSION['state'] = 1;
                header('Location: ' . $this->authurl . '?oauth_token=' . $request_token_info['oauth_token'] . '&oauth_callback=' . $this->callback_url);
                exit;
            } else {
                if ($_SESSION['state'] == 1) {
                    $oauth->setToken($_GET['oauth_token'], $_SESSION['secret']);
                    $verifier = array_key_exists('verifier', $_GET) ? $_GET['verifier'] : null;
                    $access_token_info = $oauth->getAccessToken($this->acc_url, null, $verifier);
                    $_SESSION['state'] = 2;
                    $_SESSION['token'] = $access_token_info['oauth_token'];
                    $_SESSION['secret'] = $access_token_info['oauth_token_secret'];
                }
            }
            $oauth->setToken($_SESSION['token'], $_SESSION['secret']);
            if (array_key_exists('rsvp', $_GET)) {
                // button has been pressed.
                //send the RSVP.
                if ('yes' == $_GET['rsvp']) {
                    $oauth->fetch("{$this->api_url}/rsvp", array('event_id' => $_SESSION['event'], 'rsvp' => 'yes'), OAUTH_HTTP_METHOD_POST);
                } else {
                    $response = $oauth->fetch("{$this->api_url}/rsvp", array('event_id' => $_SESSION['event'], 'rsvp' => 'no'), OAUTH_HTTP_METHOD_POST);
                }
                $rsvp = json_decode($oauth->getLastResponse());
                echo $header;
                echo '<h1 style="padding:20px 0 0;"><a>' . $rsvp->description . '</a></h1>';
                echo '<p>' . $rsvp->details . '.</p>';
                exit;
            } else {
                // Get event info to display here.
                $oauth->fetch("{$this->api_url}/2/events?event_id=" . $_SESSION['event']);
                $event = json_decode($oauth->getLastResponse());
                $event = $event->results[0];
                $out = '<h1 id="site-title" style="padding:20px 0 0;"><a target="_blank" href="' . $event->event_url . '">' . $event->name . '</a></h1>';
                $out .= '<p style="text-align:justify;">' . $event->description . '</p>';
                $out .= '<p><span class="rsvp-count">' . $event->yes_rsvp_count . ' ' . _n('attendee', 'attendees', $event->yes_rsvp_count) . '</span></p>';
                if (null !== $event->venue) {
                    $venue = $event->venue->name . ' ' . $event->venue->address_1 . ', ' . $event->venue->city . ', ' . $event->venue->state;
                    $out .= "<h3 class='event_location'>Location: <a href='http://maps.google.com/maps?q={$venue}+%28" . $event->venue->name . "%29&z=17' target='_blank'>{$venue}</a></h3>";
                } else {
                    $out .= "<p class='event_location'>Location: TBA</p>";
                }
                $out .= '<h2>' . date('F d, Y @ g:i a', intval($event->time / 1000 + $event->utc_offset / 1000)) . '</h2>';
                echo $header . $out;
                $oauth->fetch("{$this->api_url}/rsvps?event_id=" . $_SESSION['event']);
                $rsvps = json_decode($oauth->getLastResponse());
                $oauth->fetch("{$this->api_url}/members?relation=self");
                $me = json_decode($oauth->getLastResponse());
                $my_id = $me->results[0]->id;
                foreach ($rsvps->results as $user) {
                    if ($my_id == $user->member_id) {
                        echo "<h3 style='padding:20px 0 0; font-weight:normal; font-size:16px'>Your RSVP: <strong>{$user->response}</strong></h3>";
                        echo "<p>You can change your RSVP below.</p>";
//.........这里部分代码省略.........
开发者ID:rogeruiz,项目名称:codeforrva,代码行数:101,代码来源:vs_meetup_widgets.php


注:本文中的OAuth::enableDebug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。