Merhaba arkadaşlar, curl ile veri çekerken json_encode ve
$this->output->set_status_header('404'); engeline takılıyorum.
Aşağıda kullandığım curl fonksiyonun verdim.
function cek_gelsin($sayfam)
{
$ch = curl_init();
//$ch = curl_init('http://example.com/service/get_video_part');
$data = array("video_id" => "$sayfam", "part_name" => "480p", "page" => "0");
// "video_id=$sayfam&part_name=480p&page=0"
$data_string = json_encode($data);
curl_setopt($ch, CURLOPT_URL, 'http://example.com/service/get_video_part');
//cache:false
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: application/json, text/javascript, */*; q=0.01"',
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt($ch, CURLOPT_REFERER, 'http://www.cloudflare-watch.org/cgi-bin/cfsearch.cgi');
curl_setopt($ch, CURLOPT_REFERER, 'http://example.com/referer-adress.html');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
//curl_setopt($ch, CURLOPT_POSTFIELDS, "video_id=$sayfam&part_name=Alternatif+&page=0");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$exec = trim(curl_exec($ch));
curl_close($ch);
return $exec;
}
$dene="64";
echo cek_gelsin($dene);Sonuç:
@nothing@
Alttaki kod
service/get_video_part php fonksiyonuna ait.
function get_video_part(){
if($this->input->is_ajax_request()){
$this->form_validation->set_rules('video_id', 'video_id', 'required|numeric|xss_clean');
$this->form_validation->set_rules('page', 'page', 'required|numeric|xss_clean');
$this->form_validation->set_rules('part_name', 'part_name', 'required|xss_clean');
if ($this->form_validation->run() == TRUE){
$this->load->library('videos');
if($data = $this->videos->get_video_part($this->input->post('video_id'), $this->input->post('part_name'), $this->input->post('page'))){
$this->output->set_content_type('application/json')->set_output(json_encode($data));
return false;
}
}
$this->output->set_status_header('404');
}
$this->output->set_status_header('404');
echo '@nothing@';
}Bu header 404 engelini nasıl aşarım.