@ 2012-07-26T06:09:17Z <?php
$cookie_file = "cookie.txt";
$urlimdbapi='https://gdata.youtube.com/feeds/api/videos?q=Batman trailer&max-results=1&v=2.1&alt=jsonc&format=5';
$imdbapiresult=new CustomCURL($urlimdbapi, $cookie_file);
$imdbresult=$imdbapiresult->send();
$imdbs_info=json_decode($imdbresult['content'], true);
print_r($imdbs_info);
class CustomCURL{
private $fsocket;
private $header;
private $method;
private $postdata;
private $cookie_file;
public static $responseHeaders;
public static $custom_curl;
function __construct($url, $cookie_file){
$this->method='GET';
$this->fsocket = curl_init();
$this->setopt(CURLOPT_URL, $url);
$this->setopt(CURLOPT_COOKIEFILE, realpath($cookie_file));
$this->setopt(CURLOPT_COOKIEJAR, realpath($cookie_file));
$this->setopt(CURLOPT_TIMEOUT, 0);
$this->setopt(CURLOPT_RETURNTRANSFER, 1);
$this->setopt(CURLOPT_MAXREDIRS, 10);
$this->setopt(CURLOPT_CONNECTTIMEOUT, 30);
$this->setopt(CURLOPT_FOLLOWLOCATION, 1);
$this->setopt(CURLOPT_AUTOREFERER, 1);
$this->setopt(CURLINFO_HEADER_OUT, 1);
$this->setopt(CURLOPT_HEADER, 0);
$this->setopt(CURLOPT_VERBOSE, 0);
$this->setopt(CURLOPT_SSL_VERIFYPEER, 0);
$this->setopt(CURLOPT_SSL_VERIFYHOST, 0);
self::$responseHeaders=array();
$this->setopt(CURLOPT_HEADERFUNCTION,array('CustomCURL','headerFunction'));
$this->cookie_file=$cookie_file;
}
static function headerFunction($ch, $header){
$vars=explode(':',$header,2);
self::$responseHeaders[strtolower(trim($vars[0]))]=isset($vars[1])?trim($vars[1]):'';
return strlen($header);
}
function setopt($opt, $value){
return curl_setopt($this->fsocket, $opt, $value);
}
function setHeaders($array){
return $this->header = $array;
}
function setPostData($array, $isMultipart = true){
$this->method='POST';
if($isMultipart){
$this->postdata = $array;
}else{
$post='';
foreach($array as $key=>$val){
if(is_array($val)){
foreach($val as $subval){
if($post!=''){
$post.='&';
}
$post.=urlencode($key).'='.urlencode($subval);
}
}else{
if($post!=''){
$post.='&';
}
$post.=urlencode($key).'='.urlencode($val);
}
}
$this->postdata = $post;
}
}
function send($forMulti=false){
if(!empty($this->header)){
$this->setopt(CURLOPT_HTTPHEADER, $this->header);
}
if($this->method=='POST' && !empty($this->postdata)){
$this->setopt(CURLOPT_POST, 1);
$this->setopt(CURLOPT_POSTFIELDS, $this->postdata);
}
if($forMulti){
return $this->fsocket;
}
$exec = curl_exec($this->fsocket);
if(curl_errno($this->fsocket)){
$result['error'] = curl_error($this->fsocket);
}else{
$result['post_data'] = $this->postdata;
$result['content'] = $exec;
$result['info'] = curl_getinfo($this->fsocket);
$result['info']['request_headers']=curl_getinfo($this->fsocket, CURLINFO_HEADER_OUT);
$result['info']['response_headers']=self::$responseHeaders;
}
$this->debug($result, $this->cookie_file);
return $result;
}
function debug($result,$cookie){
/*
==============================
THIS IS FOR DEBUGGING PURPOSES
==============================
Comment return; to trace output
*/
return;
echo '<h1>',$result['info']['url'],'</h1>';
echo '<h2>Content</h2>';
echo '<pre>',htmlspecialchars($result['content']),'</pre>';
echo '<h2>Cookies</h2>';
echo '<pre>',@file_get_contents($cookie),'</pre>';
echo '<h2>Post Data</h2>';
echo '<pre>';
print_r($result['post_data']);
echo '</pre>';
echo '<h2>Other Info</h2>';
echo '<pre>';
print_r($result['info']);
echo '</pre>';
flush();
usleep(100);
}
function close(){
curl_close($this->fsocket);
$this->header = array();
$this->postdata = array();
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.32 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/tvCQa:23
Stack trace:
#0 /in/tvCQa(6): CustomCURL->__construct('https://gdata.y...', 'cookie.txt')
#1 {main}
thrown in /in/tvCQa on line 23
Process exited with code 255 . Output for 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.38 Fatal error: Call to undefined function curl_init() in /in/tvCQa on line 23
Process exited with code 255 . preferences:dark mode live preview
230.93 ms | 402 KiB | 400 Q