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


PHP Curl::addOption方法代码示例

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


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

示例1: post

 public function post($url, $getParameters = array(), $postParameters, $isJson = false, $curlOptions = array())
 {
     $curl = new Curl();
     $curl->setUrl($url, $getParameters);
     $curl->setMethod(true);
     if ($isJson) {
         $postParameters = json_encode($postParameters);
         $curl->addOption('HTTP_HEADER', array('Content-Type: application/json'));
     }
     $curl->setPostParameters($postParameters);
     foreach ($curlOptions as $key => $value) {
         $curl->addOption($key, $value);
     }
     return $this->send($curl, $isJson);
 }
开发者ID:fakhrishahab,项目名称:laravel_zeeza,代码行数:15,代码来源:CurlService.php

示例2: create

 /**
  * @param string $url
  * @return Curl
  */
 public function create($url)
 {
     $curl = new Curl($url);
     foreach ($this->options as $option) {
         $curl->addOption($option[0], $option[1]);
     }
     return $curl;
 }
开发者ID:phpwrapper,项目名称:curl,代码行数:12,代码来源:CurlFactory.php

示例3: postRequest

 private function postRequest($url, $fields)
 {
     $curl = new Curl();
     $curl->addHeader('Authorization: Bearer ', $fields['code']);
     $curl->addOption(CURLOPT_RETURNTRANSFER, true);
     $request = $curl->post($url, $fields);
     return $request;
 }
开发者ID:janhenckens,项目名称:wp-connect-strava,代码行数:8,代码来源:class-wp-connect-strava-auth.php

示例4: connect

 /**
  * cURL connection function. Returns data from Twitter and interfaces with
  * debug function.
  *
  * @param   bool    $login			Login to Twitter?
  * @param   bool    $post			Use POST instead of GET?
  * @param   array    $post_data		Array data for POST.
  * @return  string
  */
 private function connect($login = FALSE, $post = FALSE, $post_data = NULL)
 {
     // If credentials are required add them
     if ($login) {
         $login = $this->login;
     }
     // add default header info
     $this->headers[] = 'Expect:';
     $curl_options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_URL => $this->url);
     // curl init
     $curl = new Curl($curl_options);
     // add curl options
     if (count($this->headers) > 0) {
         $curl->addOption(CURLOPT_HTTPHEADER, $this->headers);
     }
     if ($login) {
         $curl->addOption(CURLOPT_USERPWD, $this->login);
     }
     if ($post) {
         $curl->addOption(CURLOPT_POST, TRUE);
     }
     if (is_array($post_data)) {
         $curl->addOption(CURLOPT_POSTFIELDS, $post_data);
     }
     // retrieve data
     $data = $curl->execute($this->ignore_curl_error_numbers);
     // set curl http status
     $this->status = $curl->status();
     // set last call
     $this->last = $this->url;
     // clear settings
     $this->url = '';
     $this->headers = '';
     // debug output
     //	if (!IN_PRODUCTION AND Kohana::config('twitter.debug')) $this->debugo($data, $post_data);
     return $data;
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:46,代码来源:Twitter.php

示例5: Curl

/**
 * Simple Curl Library
 *
 * @author Federico Carrizo <carrizofg@gmail.com>
 * @url http://github.com/justfede/php-simple-curl
 */
namespace fedecarrizo\curl;

require "curl.php";
# SAMPLE GET REQUEST
$curl = new Curl();
$response = $curl->get("http://devfdxx.com/lab/tools/request.php?name=Federico");
echo $response;
# SAMPLE POST REQUEST
$curl = new Curl("http://devfdxx.com/lab/tools/request.php");
$response = $curl->post(['name' => 'Federico', 'last_name' => 'Carrizo']);
echo $response;
# ENABLE DEBUG
$curl->debug = 1;
# 1 will output errors
# FREQUENTLY OPTIONS
$curl->returnTransfer = true;
$curl->followLocation = true;
$curl->header = true;
$curl->url = 'http://example.com';
$curl->timeOut = 60;
$curl->connectionTimeOut = 60;
# CUSTOM OPTIONS
$curl->addOption(CURLOPT_USERAGENT, 'Googlebot/2.1');
开发者ID:justfede,项目名称:php-simple-curl,代码行数:29,代码来源:example.php


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