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


PHP OAuthUtil::build_http_query方法代码示例

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


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

示例1: http

 /**
  * @see TwitterOAuth::http()
  * @author Naomichi Yamakita <yamakita@dtx.co.jp>
  */
 public function http($uri, $method, $postData = NULL)
 {
     // TwitterOAuth::http() はレスポンスヘッダを書き換えてるため使用しない
     // (Mars_ResponseParser の動作に影響するため)
     $sender = new Mars_HttpRequestSender($uri);
     $sender->setUserAgent($this->useragent);
     $sender->setReadTimeout($this->connecttimeout);
     $sender->addHeader('Expect', '');
     if (is_string($postData)) {
         parse_str($postData, $postData);
     }
     if ($method === 'POST') {
         $sender->setRequestMethod(Mars_HttpRequest::HTTP_POST);
         $sender->addParameters($postData);
     } else {
         if ($method === 'DELETE') {
             $sender->setRequestMethod(Mars_HttpRequest::HTTP_DELETE);
             if (sizeof($postData)) {
                 $uri = $uri . '?' . OAuthUtil::build_http_query($postData);
             }
         }
     }
     $sender->setBaseURI($uri);
     $parser = $sender->send();
     $this->http_code = $parser->getStatus();
     $this->http_info = $parser->getRawHeader();
     $this->url = $uri;
     return $parser->getContents();
 }
开发者ID:naomichi-y,项目名称:mars_plugin,代码行数:33,代码来源:Mars_TwitterOAuth.class.php

示例2: execute

 private function execute($selected_call, $method_type, $params)
 {
     // the endpoint for your request
     $endpoint = "{$this->netdnarws_url}/{$this->alias}{$selected_call}";
     //parse endpoint before creating OAuth request
     $parsed = parse_url($endpoint);
     if (array_key_exists("parsed", $parsed)) {
         parse_str($parsed['query'], $params);
     }
     //generate a request from your consumer
     require_once __DIR__ . '/OAuth/OAuthRequest.php';
     $req_req = OAuthRequest::from_consumer_and_token($this->consumer, null, $method_type, $endpoint, $params);
     //sign your OAuth request using hmac_sha1
     require_once __DIR__ . '/OAuth/OAuthSignatureMethod_HMAC_SHA1.php';
     $sig_method = new OAuthSignatureMethod_HMAC_SHA1();
     $req_req->sign_request($sig_method, $this->consumer, null);
     // create curl resource
     $ch = curl_init();
     // set url
     curl_setopt($ch, CURLOPT_URL, $req_req);
     // return the transfer as a string
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // Set SSL Verifyer off
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     // set curl timeout
     curl_setopt($ch, CURLOPT_TIMEOUT, 60);
     // set curl custom request type if not standard
     if ($method_type != "GET" && $method_type != "POST") {
         curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method_type);
     }
     if ($method_type == "POST" || $method_type == "PUT" || $method_type == "DELETE") {
         require_once __DIR__ . '/OAuth/OAuthUtil.php';
         $query_str = OAuthUtil::build_http_query($params);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:', 'Content-Length: ' . strlen($query_str)));
         curl_setopt($ch, CURLOPT_POSTFIELDS, $query_str);
     }
     // retrieve headers
     curl_setopt($ch, CURLOPT_HEADER, 1);
     curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
     //set user agent
     curl_setopt($ch, CURLOPT_USERAGENT, 'PHP NetDNA API Client');
     // make call
     $result = curl_exec($ch);
     $headers = curl_getinfo($ch);
     $curl_error = curl_error($ch);
     // close curl resource to free up system resources
     curl_close($ch);
     // $json_output contains the output string
     $json_output = substr($result, $headers['header_size']);
     // catch errors
     if (!empty($curl_error) || empty($json_output)) {
         //throw new \NetDNA\RWSException("CURL ERROR: $curl_error, Output: $json_output", $headers['http_code'], null, $headers);
         return 'CURL ERROR: ' . $curl_error . ', Output: ' . $json_output;
     }
     return $json_output;
 }
开发者ID:kenyonjohnston,项目名称:hott_theater,代码行数:56,代码来源:NetDNA.php

示例3: fetchQuery

 public static function fetchQuery($query, $ts)
 {
     if (!$query) {
         return;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $sql = "select min(ql_time_fetched) as ts from dedup.query_lookup where ql_query=" . $dbr->addQuotes($query);
     $res = $dbr->query($sql, __METHOD__);
     foreach ($res as $row) {
         $oldTs = $row->ts;
     }
     if ($oldTs > $ts) {
         $dbw = wfGetDB(DB_MASTER);
         $sql = "insert into dedup.query_lookup_log(qll_query, qll_result, qll_timestamp) values(" . $dbw->addQuotes($query) . "," . $dbw->addQuotes("exists") . "," . $dbw->addQuotes(wfTimestampNow()) . ")";
         $dbw->query($sql, __METHOD__);
         return;
     }
     try {
         $cc_key = WH_YAHOO_BOSS_API_KEY;
         $cc_secret = WH_YAHOO_BOSS_API_SECRET;
         $url = "http://yboss.yahooapis.com/ysearch/web";
         $args = array();
         $args["q"] = $query;
         $args["format"] = "json";
         $consumer = new OAuthConsumer($cc_key, $cc_secret);
         $request = OAuthRequest::from_consumer_and_token($consumer, NULL, "GET", $url, $args);
         $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL);
         $url = sprintf("%s?%s", $url, OAuthUtil::build_http_query($args));
         $ch = curl_init();
         $headers = array($request->to_header());
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         $rsp = curl_exec($ch);
         $results = json_decode($rsp);
         if ($results->bossresponse->responsecode == 200) {
             $n = 0;
             $dbw = wfGetDB(DB_MASTER);
             foreach ($results->bossresponse->web->results as $result) {
                 $n++;
                 $sql = "insert into dedup.query_lookup(ql_query,ql_url,ql_pos,ql_time_fetched) values(" . $dbw->addQuotes($query) . "," . $dbw->addQuotes($result->url) . "," . $dbw->addQuotes($n) . "," . $dbw->addQuotes(wfTimestampNow()) . ")";
                 $dbw->query($sql, __METHOD__);
             }
             $sql = "insert into dedup.query_lookup_log(qll_query, qll_result, qll_timestamp) values(" . $dbw->addQuotes($query) . "," . $dbw->addQuotes('success') . "," . $dbw->addQuotes(wfTimestampNow()) . ")";
             $dbw->query($sql, __METHOD__);
         } else {
             $dbw = wfGetDB(DB_MASTER);
             $sql = "insert into dedup.query_lookup_log(qll_query, qll_result, qll_timestamp, qll_timestamp, qll_comment) values(" . $dbw->addQuotes($query) . "," . $dbw->addQuotes('badresponse') . "," . $dbw->addQuotes(wfTimestampNow()) . "," . $dbw->addQuotes("Response : " . ($results ? print_r($results, true) : ''));
             $dbw->query($sql, __METHOD__);
         }
     } catch (Exception $ex) {
         $dbw = wfGetDB(DB_MASTER);
         $sql = "insert into dedup.query_lookup_log(qll_query, qll_result, qll_timestamp, qll_comment) values(" . $dbw->addQuotes($query) . "," . $dbw->addQuotes("exception") . "," . $dbw->addQuotes(wfTimestampNow()) . "," . $dbw->addQuotes($ex->getMessage()) . ")";
         $dbw->query($sql, __METHOD__);
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:56,代码来源:dedupQuery.php

示例4: post

 function post($url, $params = array(), $multi = false)
 {
     $query = "";
     if ($multi) {
         $query = OAuthUtil::build_http_query_multi($params);
     } else {
         $query = OAuthUtil::build_http_query($params);
     }
     $response = $this->http($url, 'POST', $query, $multi);
     return $response;
 }
开发者ID:ydhl,项目名称:yangzie,代码行数:11,代码来源:http.php

示例5: testBuildHttpQuery

 public function testBuildHttpQuery()
 {
     // Tests taken from
     // http://wiki.oauth.net/TestCases ("Normalize Request Parameters")
     $this->assertEquals('name=', OAuthUtil::build_http_query(array('name' => '')));
     $this->assertEquals('a=b', OAuthUtil::build_http_query(array('a' => 'b')));
     $this->assertEquals('a=b&c=d', OAuthUtil::build_http_query(array('a' => 'b', 'c' => 'd')));
     $this->assertEquals('a=x%20y&a=x%21y', OAuthUtil::build_http_query(array('a' => array('x!y', 'x y'))));
     $this->assertEquals('x=a&x%21y=a', OAuthUtil::build_http_query(array('x!y' => 'a', 'x' => 'a')));
     // Test taken from the Spec 9.1.1
     $this->assertEquals('a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t', OAuthUtil::build_http_query(array('a' => '1', 'c' => 'hi there', 'f' => array(25, 50, 'a'), 'z' => array('p', 't'))));
 }
开发者ID:srouthiau,项目名称:oauth,代码行数:12,代码来源:OAuthUtilTest.php

示例6: getAuthorizeURL

	/**
   * Get the authorize URL
   *
   * @returns a string
   */
  function getAuthorizeURL($response_type, $scope=null, $state=null, $display=null) {
    $params = array(
    	'client_id' => $this->client_id,
    	'response_type' => $response_type,
    	'redirect_uri' => $this->redirect_uri,
    );
    if(!empty($scope))	$params['scope'] = $scope;
    if(!empty($state))	$params['state'] = $state;
    if(!empty($display))	$params['display'] = $display;
  	$query = OAuthUtil::build_http_query($params);
	return $this->authorizeURL . "?{$query}";  
  }
开发者ID:joaosigno,项目名称:dazake-job,代码行数:17,代码来源:kxClient.php

示例7: makeSignedRequest

 public function makeSignedRequest($url, $fields)
 {
     if (isset($this->access_token)) {
         $params = array("nk_token" => $this->access_token, "fields" => $fields);
         $consumer = new OAuthConsumer($this->client_id, $this->client_secret);
         $req = OAuthRequest::from_consumer_and_token($consumer, null, 'GET', $url, $params);
         $req->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, null);
         $auth_header = $req->to_header();
         $options['headers'] = array($auth_header, 'Content-Type: application/json');
         $url = $url . "?" . OAuthUtil::build_http_query($params);
         return $this->makeRequest($url, $options);
     }
 }
开发者ID:naszaklasa,项目名称:yii-eauth-nk,代码行数:13,代码来源:NKOAuthService.php

示例8: geocode

 public function geocode($location = FALSE)
 {
     $args = $this->args();
     $request = $this->authorize($args);
     $url = sprintf("%s?%s", $this->baseUrl, OAuthUtil::build_http_query($args));
     $ch = curl_init();
     $headers = array($request->to_header());
     curl_setopt($ch, CURLOPT_ENCODING, "gzip");
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     return curl_exec($ch);
 }
开发者ID:rhgarage,项目名称:Google-Maps-for-ExpressionEngine-v3,代码行数:13,代码来源:YahooBossGeocoder.php

示例9: post

 function post($url, $params = array(), $multi = false)
 {
     $query = "";
     if ($multi) {
         $query = OAuthUtil::build_http_query_multi($params);
     } else {
         $query = OAuthUtil::build_http_query($params);
     }
     $response = $this->http($url, 'POST', $query, $multi);
     if ($this->format === 'json' && $this->decode_json) {
         return json_decode($response);
     }
     return $response;
 }
开发者ID:joaosigno,项目名称:dazake-job,代码行数:14,代码来源:kxHttpClient.php

示例10: testBuildHttpQuery

 public function testBuildHttpQuery()
 {
     // Tests taken from
     // http://wiki.oauth.net/TestCases ("Normalize Request Parameters")
     $this->assertEquals('name=', OAuthUtil::build_http_query(array('name' => '')));
     $this->assertEquals('a=b', OAuthUtil::build_http_query(array('a' => 'b')));
     $this->assertEquals('a=b&c=d', OAuthUtil::build_http_query(array('a' => 'b', 'c' => 'd')));
     $this->assertEquals('a=x%20y&a=x%21y', OAuthUtil::build_http_query(array('a' => array('x!y', 'x y'))));
     $this->assertEquals('x=a&x%21y=a', OAuthUtil::build_http_query(array('x!y' => 'a', 'x' => 'a')));
     // Test taken from the Spec 9.1.1
     $this->assertEquals('a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t', OAuthUtil::build_http_query(array('a' => '1', 'c' => 'hi there', 'f' => array(25, 50, 'a'), 'z' => array('p', 't'))));
     // From issue 164, by hidetaka
     // Based on discussion at
     // http://groups.google.com/group/oauth/browse_thread/thread/7c698004be0d536/dced7b6c82b917b2?lnk=gst&q=sort#
     $this->assertEquals('x=200&x=25&y=B&y=a', OAuthUtil::build_http_query(array('x' => array(25, 200), 'y' => array('a', 'B'))));
 }
开发者ID:tholu,项目名称:restapi-php-sdk,代码行数:16,代码来源:OAuthUtilTest.php

示例11: executeAuthorizeToken

 public function executeAuthorizeToken(sfWebRequest $request)
 {
     $this->token = $request->getParameter('oauth_token');
     $this->information = $this->getTokenTable()->findByKeyString($this->token);
     $this->forward404Unless($this->information);
     if ($request->isMethod(sfWebRequest::POST)) {
         $url = $this->information->getCallbackUrl();
         $params = array('oauth_token' => $this->token, 'oauth_verifier' => $this->information->getVerifier());
         $query = (false === strpos($url, '?') ? '?' : '&') . OAuthUtil::build_http_query($params);
         $this->information->setIsActive(true);
         $this->information->save();
         $this->redirectUnless('oob' === $url, $url . $query);
         return sfView::SUCCESS;
     }
     return sfView::INPUT;
 }
开发者ID:Kazuhiro-Murota,项目名称:OpenPNE3,代码行数:16,代码来源:opOAuthTokenAction.class.php

示例12: fetchQueryFromYBoss

 public static function fetchQueryFromYBoss($row)
 {
     $query = self::makeHowToQuery($row[KeywordIdeasCSV::KEY_KEYWORD]);
     if (empty($query)) {
         return;
     }
     $cc_key = WH_YAHOO_BOSS_API_KEY;
     $cc_secret = WH_YAHOO_BOSS_API_SECRET;
     $url = "http://yboss.yahooapis.com/ysearch/web";
     $args = array();
     $args["q"] = $query;
     $args["format"] = "json";
     $consumer = new OAuthConsumer($cc_key, $cc_secret);
     $request = OAuthRequest::from_consumer_and_token($consumer, NULL, "GET", $url, $args);
     $request->sign_request(new OAuthSignatureMethod_HMAC_SHA1(), $consumer, NULL);
     $url = sprintf("%s?%s", $url, OAuthUtil::build_http_query($args));
     $ch = curl_init();
     $headers = array($request->to_header());
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     $rsp = curl_exec($ch);
     $results = json_decode($rsp);
     $totalResults = 0;
     if ($results->bossresponse->responsecode == 200) {
         $totalResults = $results->bossresponse->web->totalresults;
         $titles = array();
         foreach ($results->bossresponse->web->results as $idx => $result) {
             $title = self::getShortTitle($result->title);
             if (self::isHowToResult($title) == 1) {
                 $csvRow = array();
                 $csvRow[self::KEY_POS_IN_RESULTS] = $idx;
                 $csvRow[self::KEY_ORIG_TITLE] = $result->title;
                 $csvRow[self::KEY_SHORT_TITLE] = $result->title;
                 $csvRow[self::KEY_SHORT_TITLE] = $title;
                 $csvRow[self::KEY_SITE] = self::getDomain($result->url);
                 $csvRow[self::KEY_URL] = $result->url;
                 $titles[] = $csvRow;
             }
         }
     } else {
         $err = "Error in fetching reults from boss for kw=[{$query}]. Resp code = " . $results->bossresponse->responsecode . "<br>\n";
     }
     return array($err, $totalResults, $titles);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:45,代码来源:YBSuggestions.php

示例13: howToGetRequestToken

 /**
  * リクエストトークンの取得方法サンプル
  */
 function howToGetRequestToken()
 {
     //
     // Google Data APIを利用する場合には"scope"パラメータが必須
     // 参考:http://code.google.com/intl/ja/apis/accounts/docs/OAuth_ref.html#RequestToken
     // 参考:http://code.google.com/intl/ja/apis/gdata/faq.html#AuthScopes
     //
     $additional_param = array('scope' => 'https://www.google.com/calendar/feeds/');
     //
     // request tokenを取得
     //
     $req_token = OAuthWrapUtil::get_request_token($this->target_consumer, $additional_param);
     print $req_token . "\n";
     //
     // user authorizatio url
     //
     $auth_url = OAuthWrapUtil::get_user_authorization_url($this->target_consumer);
     print $auth_url . '?' . OAuthUtil::build_http_query(array('oauth_token' => $req_token->key)) . "\n";
 }
开发者ID:omix222,项目名称:oauth-wrap,代码行数:22,代码来源:HowToUse.php

示例14: to_postdata

 /**
  * builds the data one would send in a POST request
  */
 public function to_postdata($raw = false)
 {
     if ($raw) {
         return $this->parameters;
     } else {
         return OAuthUtil::build_http_query($this->parameters);
     }
 }
开发者ID:ZerGabriel,项目名称:friendica,代码行数:11,代码来源:OAuth1.php

示例15: to_postdata

 /** 
  * builds the data one would send in a POST request 
  */
 public function to_postdata($multi = false)
 {
     if ($multi) {
         return OAuthUtil::build_http_query_multi($this->parameters);
     } else {
         return OAuthUtil::build_http_query($this->parameters);
     }
 }
开发者ID:dalinhuang,项目名称:shopexts,代码行数:11,代码来源:oauth.php


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