'send json parameters to webservices

I got a task to scrap data from a site. Here is the site http://www.centris.ca/en/for-sale What i need to do is to scrap all the properties details. Below you will see pagination in slider form. By changing page value it call webservice and can see the parameters as well.

This is where the request goes [http://www.centris.ca/Services/PropertyService.asmx/GetPropertyViews]

and these are POST values

{"pageIndex":1,"track":true}

I tried sending request to this webservice using ajax and curl but no luck. Using ajax, with all good it gives me error of cross domain issue. As the webservice is on another domain and i am requesting from another one.

 $.ajax({
         type: 'POST',
         contentType: 'application/json; charset=UTF-8',
         url: "http://www.centris.ca/Services/PropertyService.asmx/GetPropertyViews",
         data: '{"pageIndex":2,"track":true}',
         dataType: 'jsonp',
         async: true,
         success: function(msg){
        alert(msg);
    },
         error: function (msg) {
        alert(msg.statusText);
    }
     })

I tried using CURL as well

 $data = array("pageIndex" => 10, "track" => true);                                                                    
 $data_string = json_encode($data);                                                                                   

$ch = curl_init('http://www.centris.ca/Services/PropertyService.asmx/GetPropertyViews?callback=?');                                                                      
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
'Content-Type: application/json',                                                                                
'Content-Length: ' . strlen($data_string)));                                                                                                                  
$result = curl_exec($ch);

But it did not helped. It give me output as "The object is moved here", cause it redirects to error page.

Any help will be appreciated. If my question is not clear, please let me know.

Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source