Example #1
0
 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');
 }
Example #2
0
 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());
 }
Example #3
0
 public static function getIp()
 {
     $co = new Curl(self::$ifconfigIp);
     $co->setopt(CURLOPT_RETURNTRANSFER, true);
     $ip = $co->exec();
     return $ip;
 }
Example #4
0
 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;
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
<?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();
Example #7
0
<?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();
Example #8
0
<?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;
Example #9
0
<?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();