ajax - PHP CURL post giving an unknown error -


  • i'm trying ajax response posting parameters through php curl post request

  • i in need getting results website(data crawling).

  • the website using ajax calls populate results inside.

  • i had inspected ajax request made in site through firebug , when 'post'ed same request url through restclient debugger,i got results json.

  • then tried post request url through php curl post method, i'm getting invalid output.

my code

<?php $ch = curl_init(); $url = 'http://www.example.com/hotel-search?inpajax=true&responsive=true'; $fields = array(     'enddate'=>'04/15/2014',     'hashparam'=>'b2c21a315f0a0fb3f0c39f60xxxxxx',     'startdate'=>'04/14/2014', ); $headers = array(     'accept:    application/json, text/javascript,text/html' );  $agent = '  mozilla/5.0 (windows nt 5.1; rv:28.0) gecko/20100101 firefox/28.0'; curl_setopt($ch, curlopt_url, $url);  curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_useragent, $agent); //curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_postfields, http_build_query($fields)); $result = curl_exec($ch) or die(curl_error($ch)); var_dump($result);  ?> 

output

**string(20) "�"**  

edit

with reference suggestion below, have added

curl_setopt($ch, curlopt_encoding, ""); 

now i'm getting error follows,

couldn't resolve host 'www.example.com' 

looks gzip content me. use header handle this:

curl_setopt($ch, curlopt_encoding, ""); 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -