本文整理汇总了PHP中Curl::setopt方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::setopt方法的具体用法?PHP Curl::setopt怎么用?PHP Curl::setopt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curl
的用法示例。
在下文中一共展示了Curl::setopt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPutFileHandle
public function testPutFileHandle()
{
$png = $this->create_png();
$tmp_file = $this->create_tmp_file($png);
$this->curl->setopt(CURLOPT_PUT, TRUE);
$this->curl->setopt(CURLOPT_INFILE, $tmp_file);
$this->curl->setopt(CURLOPT_INFILESIZE, strlen($png));
$this->curl->put(self::TEST_URL . '/server.php', array('test' => 'put_file_handle'));
fclose($tmp_file);
$this->assertTrue($this->curl->response === 'image/png');
}
示例2: testCurlWrapperCanDoHttpQueries
function testCurlWrapperCanDoHttpQueries()
{
$curl = new Curl(self::TEST_VALID_URL);
$curl->setopt(CURLOPT_PROXY, $this->proxy);
$this->assertTrue($curl->setopt(CURLOPT_RETURNTRANSFER, 1));
$this->assertTrue($curl->setopt_array(array(CURLOPT_TIMEOUT => self::CURL_TIMEOUT, CURLOPT_FOLLOWLOCATION => true)));
$result = $curl->exec();
$this->assertStringStartsWith('<!doctype html>', $result);
$curl->close();
$this->assertFalse($curl->hasHandle());
}
示例3: getIp
public static function getIp()
{
$co = new Curl(self::$ifconfigIp);
$co->setopt(CURLOPT_RETURNTRANSFER, true);
$ip = $co->exec();
return $ip;
}
示例4: getCurl
public function getCurl($url)
{
$co = new Curl($url);
$co->setopt(CURLOPT_RETURNTRANSFER, true);
$co->readCookies($this->cookie);
$co->storeCookies($this->cookie);
$co->setUserAgent("Mozilla/5.0 (X11; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0");
return $co;
}
示例5: exec
/**
* Executes the query and returns
*
* @return YQL_Iterator
* @return YQL_Result
* @author Sam Clark
* @access protected
*/
protected function exec()
{
// If the query hasn't been rendered, render it
if ($this->query === NULL) {
$this->render_query();
}
// Execute the query
$data = $this->curl->setopt(CURLOPT_URL, $this->format_query($this->query))->exec()->result();
// Run the post execute
Event::run('yql.post_execute');
return $this->parse($data);
}
示例6: Curl
<?php
include '../lib/Curl.php';
include '../lib/Curl/Share.php';
/**
* curl_share_init() example
*
* http://php.net/manual/en/function.curl-share-init.php#refsect1-function.curl-share-init-examples
*/
// Create cURL share handle and set it to share cookie data
$sh = new Curl\Share();
$sh->setopt(CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
// Initialize the first cURL handle and assign the share handle to it
$ch1 = new Curl("http://example.com/");
$ch1->setopt(CURLOPT_SHARE, $sh);
// Execute the first cURL handle
$ch1->exec();
// Initialize the second cURL handle and assign the share handle to it
$ch2 = new Curl("http://php.net/");
$ch2->setopt(CURLOPT_SHARE, $sh);
// Execute the second cURL handle
// all cookies from $ch1 handle are shared with $ch2 handle
$ch2->exec();
// Close the cURL share handle
$sh->close();
// Close the cURL handles
$ch1->close();
$ch2->close();
示例7: Curl
<?php
include '../lib/Curl.php';
include '../lib/Curl/Multi.php';
/**
* curl_multi_close() example
*
* http://php.net/manual/en/function.curl-multi-close.php#refsect1-function.curl-multi-close-examples
*/
// create both cURL resources
$ch1 = new Curl();
$ch2 = new Curl();
// set URL and other appropriate options
$ch1->setopt(CURLOPT_URL, "http://www.example.com/");
$ch1->setopt(CURLOPT_HEADER, 0);
$ch2->setopt(CURLOPT_URL, "http://www.php.net/");
$ch2->setopt(CURLOPT_HEADER, 0);
//create the multiple cURL handle
$mh = new Curl\Multi();
//add the two handles
$mh->add_handle($ch1);
$mh->add_handle($ch2);
$running = null;
//execute the handles
do {
$mh->exec($running);
} while ($running > 0);
//close the handles
$mh->remove_handle($ch1);
$mh->remove_handle($ch2);
$mh->close();
示例8: Curl
<?php
require_once __DIR__ . "/../../src/utils/Curl.php";
$curl = new Curl("http://learning.tunapanda.org/wp-content/plugins/wp-remote-sync/tests/lab/recvfile.php");
$curl->setopt(CURLOPT_RETURNTRANSFER, TRUE);
$curl->setopt(CURLOPT_POST, 1);
$curl->addFileUpload("thefile.txt", __DIR__ . "/file.txt");
$res = $curl->exec();
echo $res;
示例9: Curl
<?php
include '../lib/Curl.php';
/**
* curl_init() example
*
* http://php.net/manual/en/function.curl-init.php#refsect1-function.curl-init-examples
*/
// create a new cURL resource
$ch = new Curl();
// set URL and other appropriate options
$ch->setopt(CURLOPT_URL, "http://www.example.com/");
$ch->setopt(CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
$ch->exec();
// close cURL resource, and free up system resources
$ch->close();