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


PHP Curl::setHeader方法代码示例

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


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

示例1: send

 public function send($url, $method, array $parameters = [], array $postParameters = [], array $header = [], $content = '')
 {
     $this->curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $this->curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $method = strtolower($method);
     $finalUrl = strpos($url, '//') !== false ? $url : $this->url . $url;
     if (!empty($this->authorization) && empty($header['Authorization'])) {
         $authClass = 'Bennsel\\WindowsAzureCurl\\Service\\Authorization\\' . $this->authorization;
         $class = new $authClass($this->settings);
         $header['Authorization'] = $class->getAuthorizationString($url, $method, $parameters, $header);
     }
     if ($content && is_object($content) && method_exists($content, 'toArray')) {
         $parameters = $content->toArray();
     }
     foreach ($header as $key => $value) {
         $this->curl->setHeader($key, $value);
     }
     $orgHeader = $header;
     $r = $this->curl->{$method}($finalUrl, $parameters ?: $postParameters);
     if ($this->curl->http_status_code == 301) {
         $this->url = $this->curl->response_headers['Location'];
         return $this->send($url, $method, $parameters, $postParameters, $orgHeader, $content);
     }
     return ResponseModelMapping::create($url, $r);
 }
开发者ID:bennsel,项目名称:azure-for-php-curl,代码行数:25,代码来源:RestClient.php

示例2: _processTask

 protected function _processTask()
 {
     try {
         $curl = new Curl();
         $curl->setUserAgent('got/Tarth');
         if ($this->includeTarthHeader) {
             $curl->setHeader(\Tarth\Tool\Task::HEADER_ALLERIA_CRC, \Tarth\Tool\Task::getTarthHeader($this));
         }
         if (isset($this->header)) {
             foreach ($this->header as $key => $value) {
                 $curl->setHeader($key, $value);
             }
         }
         call_user_func_array(array($curl, strtolower($this->method)), array($this->url, $this->data));
         if ($curl->error) {
             return false;
         } else {
             //响应码大于300为请求失败
             return $curl->httpStatusCode < 300;
             //接口返回为json格式,返回值中有code为0
             //return $curl->response->code == 0;
         }
     } catch (Exception $e) {
     }
 }
开发者ID:pythias,项目名称:Tarth,代码行数:25,代码来源:ApiTask.php

示例3: login

 /**
  * @author mohuishou<1@lailin.xyz>
  * @return $this
  * @throws \Exception
  */
 protected function login()
 {
     //判断是否已经登录
     if (!empty($this->_login_cookie)) {
         return $this;
     }
     //设置header伪造来源以及ip
     $ip = rand(1, 233) . '.' . rand(1, 233) . '.' . rand(1, 233) . '.' . rand(1, 233);
     $this->_curl->setHeader("X-Forwarded-For", $ip);
     $this->_curl->setHeader("Referer", 'http://202.115.47.141/login.jsp');
     $param = ["zjh" => $this->_uid, "mm" => $this->_password];
     $this->_curl->post('http://202.115.47.141/loginAction.do', $param);
     if ($this->_curl->error) {
         throw new \Exception('Error: ' . $this->_curl->errorCode . ': ' . $this->_curl->errorMessage, 5001);
     }
     //判断是否登录成功
     $page = $this->_curl->response;
     $page = iconv('GBK', 'UTF-8//IGNORE', $page);
     $rule = ['err' => ['.errorTop', 'text']];
     $err = QueryList::Query($page, $rule)->data;
     if (!empty($err)) {
         throw new \Exception('Error:' . $err[0]['err'], 4011);
     }
     //登录成功之后设置cookie
     $this->_login_cookie = $this->_curl->getResponseCookie("JSESSIONID");
     $this->_curl->setCookie('JSESSIONID', $this->_login_cookie);
     return $this;
 }
开发者ID:mohuishou,项目名称:scuplus-jwc-package,代码行数:33,代码来源:JwcBase.php

示例4: sendSparqlUpdateQuery

 /**
  *
  * @param string $query
  * @return
  * @throw
  */
 public function sendSparqlUpdateQuery($query)
 {
     // TODO extend Accept headers to further formats
     $this->client->setHeader("Accept", "application/sparql-results+json");
     $this->client->setHeader("Content-Type", "application/sparql-update");
     return $this->client->get($this->url, array("query" => $query));
 }
开发者ID:guitarmarx,项目名称:Saft,代码行数:13,代码来源:Client.php

示例5: _request

 /**
  * 请求服务器
  * @param string $method
  * @param $path
  * @param $data
  * @return null
  */
 protected function _request($path, $data, $method = 'POST')
 {
     $this->_client->setHeader('X-AVOSCloud-Application-Id', $this->appId);
     $this->_client->setHeader('X-AVOSCloud-Application-Key', $this->appKey);
     $this->_client->setHeader('Content-Type', 'application/json');
     $this->_client->{$method}($this->apiUrl . $path, Json::encode($data));
     return $this->_client->response;
 }
开发者ID:sparui,项目名称:yii2-leancloud,代码行数:15,代码来源:LeanCloud.php

示例6: __construct

 /**
  * @param string $apiKey
  * @param string $version
  * @param string $host
  */
 public function __construct($apiKey, $version = 'v1', $host = 'https://api.persistiq.com')
 {
     $this->apiKey = $apiKey;
     $this->version = $version;
     $this->host = $host;
     $this->curl = new Curl($host . '/' . $version . '/');
     $this->curl->setHeader('x-api-key', $apiKey);
     $this->curl->setHeader('Content-Type', 'application/json');
 }
开发者ID:phillipsnick,项目名称:persistiq,代码行数:14,代码来源:PersistIQ.php

示例7: setUp

 public function setUp()
 {
     $this->client = Login::authenticate();
     $cookies = $this->client->getRequest()->getCookies();
     $curl = new Curl();
     $curl->setHeader('User-Agent', Login::$ua);
     $curl->setHeader('Cookie', Login::setCookie($cookies));
     $this->curl = $curl;
 }
开发者ID:vNative,项目名称:vnative,代码行数:9,代码来源:CrudTest.php

示例8: appointmentsTimeline

 public function appointmentsTimeline()
 {
     $curl = new Curl();
     $curl->setHeader("X-Parse-Application-Id", "yPPe3Uv46pKNnrTc7I6xArFHi8EQ8cdz4Kw3JGkX");
     $curl->setHeader("X-Parse-REST-API-Key", "7PJB1F4g8aFSv5f8e0gSMwi9Ghv2AeAkTW0O50pe");
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $curl->get('http://52.24.133.167/stripe/index.php/api/v1/history/appointments');
     return $curl->response;
 }
开发者ID:JohnOscar-Mendoza,项目名称:lb_cms,代码行数:10,代码来源:Dashboard_model.php

示例9: __construct

 /**
  * Make the call
  *
  * @author Koen Blokland Visser
  *
  * @param $hash
  * @param $callId
  *
  * @return array
  */
 public function __construct($hash, $callId)
 {
     $curl = new Curl();
     $curl->setHeader('Content-Type', 'application/json');
     $curl->setHeader('Accept', 'application/json');
     $curl->setHeader('Hash', $hash);
     $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
     $curl->get('https://api.voipgrid.nl/api/clicktodial/' . $callId . '/');
     /** @var array $response */
     $this->response = json_decode($curl->response, true);
 }
开发者ID:koenster,项目名称:php-voys,代码行数:21,代码来源:VoysCallStatus.php

示例10: sendTopic

 public function sendTopic($topic, $param)
 {
     $this->validate($topic, $param);
     $data = array('to' => $topic, 'data' => $param);
     $curl = new Curl();
     $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
     $curl->setHeader('Content-Type', 'application/json');
     $curl->setHeader('Authorization', "key={$this->key}");
     $curl->post($this->gcm_link, json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
     if ($curl->error) {
         throw new \Exception("Curl Post Error : " . $curl->error_message);
     }
     return $curl->response;
 }
开发者ID:frknikiz,项目名称:fast-gcm-topic,代码行数:14,代码来源:FastGcmTopic.php

示例11: __construct

 public function __construct($login, $hash, $subdomain, ICookieContainer $cookieContainer)
 {
     $this->_login = $login;
     $this->_hash = $hash;
     $this->_subdomain = $subdomain;
     $this->cookieContainer = $cookieContainer;
     $this->_curl = new Curl();
     $this->_curl->setUserAgent('amoCRM-API-client/1.0');
     $this->_curl->setHeader('Content-Type', 'application/json');
     $this->_curl->setOpt(CURLOPT_HEADER, false);
     $this->_curl->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
     $this->_curl->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
     $this->auth();
 }
开发者ID:nanodesu88,项目名称:amocrm,代码行数:14,代码来源:AmoCrm.php

示例12: applyCurlOptions

 /**
  * Apply cURL options
  */
 private function applyCurlOptions()
 {
     $this->curl->reset();
     $this->curl->setUserAgent('Shopello-PHP API Client/1.0');
     $this->curl->setHeader('X-API-KEY', $this->apiKey);
     $this->curl->setOpt(CURLOPT_ENCODING, 'gzip');
     $this->curl->setOpt(CURLOPT_HEADER, false);
     $this->curl->setOpt(CURLOPT_NOBODY, false);
     $this->curl->setOpt(CURLOPT_CONNECTTIMEOUT, 3);
     $this->curl->setOpt(CURLOPT_TIMEOUT, 300);
     foreach ($this->curlOptions as $key => $value) {
         $this->curl->setOpt($key, $value);
     }
 }
开发者ID:raket,项目名称:Shopello-PHP,代码行数:17,代码来源:ApiClient.php

示例13: postData

 public function postData($api_url, $api_opts = FALSE)
 {
     $curl = new Curl();
     $curl->setHeader('Content-Type', 'application/json');
     $curl->setHeader('Authorization', 'Bearer ' . $_SESSION['access_token']);
     $curl->post($api_url, $api_opts);
     if ($this->debug) {
         var_dump($curl);
     }
     if ($curl->error) {
         return $this->apiError($curl->response);
     } else {
         return array('Eskimo' => $curl->response);
     }
 }
开发者ID:si77,项目名称:Eskimo-API,代码行数:15,代码来源:eskimo.php

示例14: getData

 /**
  * docomoの対話APIを叩いてレスポンスを貰ってくる
  *
  * @param string $apikey    docomoAPIキー
  * @param string $context   会話のコンテキストID(API仕様参照)
  * @param string $mode      会話のモード(API仕様参照
  * @param string $nickname  会話している人間側の名前
  * @param string $text      人間側の入力テキスト
  * @return stdClass         レスポンスのJSONをデコードしたオブジェクト
  * @throws \Exception       サーバとの通信に失敗した場合
  */
 private function getData($apikey, $context, $mode, $nickname, $text)
 {
     $userData = ['utt' => (string) $text, 'context' => (string) $context, 'nickname' => (string) $nickname, 'mode' => (string) $mode];
     $url = sprintf('https://api.apigw.smt.docomo.ne.jp/dialogue/v1/dialogue?APIKEY=%s', rawurlencode($apikey));
     Log::info("docomo対話APIを呼び出します");
     Log::info("URL: " . $url);
     Log::info("パラメータ:");
     Log::info($userData);
     $curl = new Curl();
     $curl->setHeader('Content-Type', 'application/json; charset=UTF-8');
     $ret = $curl->post($url, json_encode($userData));
     if ($curl->error) {
         Log::error(sprintf("docomo対話APIの呼び出しに失敗しました: %d: %s", $curl->error_code, $curl->error_message));
         throw new \Exception('docomo dialogue error: ' . $curl->error_code . ': ' . $curl->error_message);
     }
     Log::info("docomoからのデータ:");
     Log::info($ret);
     if (is_object($ret) && isset($ret->utt)) {
         if ($ret->utt == '') {
             Log::warning("  docomo 指示文章が空です");
         } else {
             Log::success("  docomo 指示文章: " . $ret->utt);
         }
         return $ret;
     }
     Log::error("docomoから受け取ったデータが期待した形式ではありません:");
     Log::error($ret);
     throw new \Exception('Received an unexpected data from docomo server');
 }
开发者ID:nonoliri,项目名称:chomado_bot,代码行数:40,代码来源:Chat.php

示例15: _html

 protected function _html()
 {
     $curl = new Curl();
     $curl->setHeader('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36');
     $curl->setOpt(CURLOPT_FOLLOWLOCATION, true);
     $html = $curl->get($this->url);
     return $html;
 }
开发者ID:vNative,项目名称:vnative,代码行数:8,代码来源:Scrape.php


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