• 21-01-2015, 12:48:06
    #1
    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.
  • 22-01-2015, 19:27:53
    #2
    imkanın varsa file_get_contents dene derim.
  • 23-01-2015, 00:28:50
    #3
    hddntha adlı üyeden alıntı: mesajı görüntüle
    imkanın varsa file_get_contents dene derim.
    hocam header 404 engeli oldugu için işe yaramaz hocam.
  • 23-01-2015, 01:24:35
    #4
    Şu kodları bir dene muhtemelen sorun kalmayacaktır, ci kodlarını inceleme fırsatım yok ama yine çalışmazsa buraya is_ajax_request methodunun içeriğini yazarsan net çözümü belirtirim.

    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(                                                                           
            'X-Requested-With: XMLHttpRequest',
            '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);
  • 23-01-2015, 10:08:00
    #5
    Seyranli adlı üyeden alıntı: mesajı görüntüle
    Şu kodları bir dene muhtemelen sorun kalmayacaktır, ci kodlarını inceleme fırsatım yok ama yine çalışmazsa buraya is_ajax_request methodunun içeriğini yazarsan net çözümü belirtirim.

    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(                                                                           
            'X-Requested-With: XMLHttpRequest',
            '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);
    malesef sonuç @nothing@ şeklinde oldu. pm ile kodu ileteyim birde öyle bakın siz deneyin.
  • 24-01-2015, 17:25:26
    #6
    Kimlik doğrulama veya yönetimden onay bekliyor.
    ufukt51 adlı üyeden alıntı: mesajı görüntüle
    malesef sonuç @nothing@ şeklinde oldu. pm ile kodu ileteyim birde öyle bakın siz deneyin.
    Hocam bana iletebilirseniz bende yardımcı olmak isterim.
  • 24-01-2015, 19:51:56
    #7
    ufukt51 adlı üyeden alıntı: mesajı görüntüle
    malesef sonuç @nothing@ şeklinde oldu. pm ile kodu ileteyim birde öyle bakın siz deneyin.
    Kodu banada atarsanız, bende bakabilirim.