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


PHP OAuthRequest::to_header方法代码示例

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


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

示例1: send

 /**
  * Sends a request and returns the response 
  * 
  * @return string
  */
 public function send()
 {
     $url = $this->getURL();
     $data = $this->getData();
     $method = $this->getMethod();
     $ch = curl_init();
     $options = $this->_options;
     curl_setopt_array($ch, array(CURLOPT_USERAGENT => $options->useragent, CURLOPT_CONNECTTIMEOUT => $options->connection_timeout, CURLOPT_TIMEOUT => $options->timeout, CURLOPT_RETURNTRANSFER => true, CURLINFO_HEADER_OUT => true, CURLOPT_SSL_VERIFYPEER => $options->ssl, CURLOPT_HEADER => false));
     $headers = array();
     //if data is string then
     //set the authorization header
     //A Hack to make the linked-in work wihtout affecting
     //other services
     if (is_string($this->_data)) {
         $headers[] = $this->_internal_request->to_header();
         $headers[] = "Content-Type: text/plain";
     }
     if (!empty($headers)) {
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     }
     switch ($method) {
         case KHttpRequest::POST:
             curl_setopt($ch, CURLOPT_POST, true);
             if (!empty($data)) {
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
             }
             break;
         case KHttpRequest::PUT:
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
             if (!empty($data)) {
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
             }
             break;
         case KHttpRequest::DELETE:
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
             if (!empty($data)) {
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
             }
     }
     curl_setopt($ch, CURLOPT_URL, $url);
     $response = curl_exec($ch);
     return new ComConnectOauthResponse($response, curl_getinfo($ch));
 }
开发者ID:walteraries,项目名称:anahita,代码行数:48,代码来源:request.php

示例2: http

 /**
  * Make an HTTP request
  *
  * @return API results
  */
 function http($url, $method, $postfields = NULL, OAuthRequest $request = NULL, $multipart = false)
 {
     $this->http_info = array();
     $ci = curl_init();
     /* Curl settings */
     curl_setopt($ci, CURLOPT_USERAGENT, $this->useragent);
     curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
     curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
     curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
     $headers = array('Expect:');
     if ($multipart) {
         $headers[] = $request->to_header();
     }
     curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
     curl_setopt($ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader'));
     curl_setopt($ci, CURLOPT_HEADER, FALSE);
     switch ($method) {
         case 'POST':
             curl_setopt($ci, CURLOPT_POST, TRUE);
             if (!empty($postfields)) {
                 curl_setopt($ci, CURLOPT_POSTFIELDS, $postfields);
             }
             break;
         case 'DELETE':
             curl_setopt($ci, CURLOPT_CUSTOMREQUEST, 'DELETE');
             if (!empty($postfields)) {
                 $url = "{$url}?{$postfields}";
             }
     }
     curl_setopt($ci, CURLOPT_URL, $url);
     $response = curl_exec($ci);
     $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
     $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
     $this->url = $url;
     curl_close($ci);
     return $response;
 }
开发者ID:sumobi,项目名称:post-promoter-pro,代码行数:43,代码来源:twitteroauth.php

示例3: http

 /**
  * HTTP通信を行う。
  * 
  * @param OAuthRequest $request リクエストオブジェクト
  * @param array $body_params POSTのBODYに指定するパラメータ
  * @return HttpResponse
  */
 private static function http($request, $body_params = array())
 {
     // cURLリソースの生成
     $ch = curl_init();
     // Locationヘッダは無視
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
     // サーバ証明書の検証を行わない
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     // レスポンスを文字列として取得する設定
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     // (出力結果に)ヘッダを含める
     curl_setopt($ch, CURLOPT_HEADER, true);
     if (strcasecmp($request->get_normalized_http_method(), 'POST') == 0) {
         // POST通信
         curl_setopt($ch, CURLOPT_POST, true);
         // URLを指定
         curl_setopt($ch, CURLOPT_URL, $request->get_normalized_http_url());
         // リクエストヘッダを設定
         curl_setopt($ch, CURLOPT_HTTPHEADER, array($request->to_header()));
         // リクエストパラメータを設定
         curl_setopt($ch, CURLOPT_POSTFIELDS, $body_params);
     } else {
         // URLを指定
         curl_setopt($ch, CURLOPT_URL, $request->to_url());
     }
     // 実行
     $result = curl_exec($ch);
     // HTTPステータスコードを取得
     $http_status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     // close curl resource to free up system resources
     curl_close($ch);
     return explode("\r\n\r\n", $result, 2);
 }
开发者ID:omix222,项目名称:oauth-wrap,代码行数:41,代码来源:OAuthWrapUtil.php

示例4: _performRequest

 /**
  * Performs a OAuthRequest, returning the response
  * You can give a token to force signatures with this
  * token. If none given, the token used when creating
  * this instance of CampusNotesAPI is used
  * @param OAuthRequest $req
  * @param OAuthToken $token 
  * @return string
  * @throws CNApiException
  */
 private function _performRequest(OAuthRequest $req, OAuthToken $token = null)
 {
     $token = $token ? $token : $this->oauth_token;
     $req->sign_request($this->hmac_signature_method, $this->oauth_consumer, $token);
     $curl = curl_init();
     $params = $req->get_parameters();
     foreach (array_keys($params) as $i) {
         if (substr($i, 0, 6) == 'oauth_') {
             unset($params[$i]);
         }
     }
     $url = $req->get_normalized_http_url();
     if ($req->get_normalized_http_method() == 'POST') {
         curl_setopt($curl, CURLOPT_POST, true);
         curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
     } else {
         if (count($params)) {
             $url .= '?' . http_build_query($params);
         }
     }
     curl_setopt($curl, CURLOPT_URL, $url);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array($req->to_header()));
     $rtn = curl_exec($curl);
     if (!$rtn) {
         throw new OAuthClientException(curl_error($curl));
     } else {
         if (curl_getinfo($curl, CURLINFO_HTTP_CODE) != 200) {
             throw new OAuthClientException($rtn);
         } else {
             return $rtn;
         }
     }
 }
开发者ID:redspider,项目名称:Entrecredits-API,代码行数:44,代码来源:EccOAuth.php

示例5: __build_oauth_header

 private function __build_oauth_header($linkedin_url)
 {
     $request = new OAuthRequest('GET', $linkedin_url, array('oauth_nonce' => OAuthRequest::generate_nonce(), 'oauth_timestamp' => OAuthRequest::generate_timestamp(), 'oauth_version' => '1.0', 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_consumer_key' => $this->oaConsumerKey, 'oauth_token' => OAUTH_USER_TOKEN));
     $request->sign_request($this->signature, new OAuthConsumer('', $this->oaConsumerSecret), new OAuthToken('', '95b27494-0a99-47c0-a66c-533cef4b8a28'));
     return $request->to_header();
 }
开发者ID:manoj-samosys,项目名称:linkedin-api-quick-start-php,代码行数:6,代码来源:linkedin.php


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