本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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');