0

please help me to receive josn data from this site, need to make imei check don't know how to get their response. Tried php porxy page, but unsuccessfull

they use this script, but origin don't let me make crossdomain AJAX Thanks for attention

    $.ajax({ type: "POST", url: "http://iphoneimei.info/json/unlock/request" , 
    data: {imei: '012651006507772'} ,
    error:  function() { 
            $("#unlock-msg").html('<span class="red"> Error </span>');
            $("#unlock-loading").hide();
            $("#unlock-main-div").fadeOut("fast");
        },
    success: function(data) {
        alert(data.msg);            
    }
,dataType: "json"});
Amir Anvarov
  • 107
  • 1
  • 9
  • so what does the PHP proxy give you? why was it unsuccessfull? – Zathrus Writer Sep 30 '13 at 11:21
  • use jsonp for crossdomain requests: http://api.jquery.com/jQuery.getJSON/ – Tomer Sep 30 '13 at 11:23
  • i don't know how to send POST request via file_get_contents() looked in stackoverflow same but have problem with this site. if you can please show me working script to get theire reponce json – Amir Anvarov Sep 30 '13 at 11:24
  • i'd use JSONP but as i know it sends GET request but this site uses POST this is a problem – Amir Anvarov Sep 30 '13 at 11:25
  • _“i don't know how to send POST request via file_get_contents() ”_ – user comments in the manual are often a good source for additional info, so please look through them first next time! http://www.php.net/manual/en/function.file-get-contents.php#108309 – CBroe Sep 30 '13 at 11:57

1 Answers1

0

I would try using CURL:

$urltopost = "http://iphoneimei.info/json/unlock/request";
$datatopost = array (
    "imei" => "012651006507772",
);
$data_string = json_encode($datatopost);
$ch = curl_init ($urltopost);

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',
        'Accept: application/json',
        'Content-Length: ' . strlen($data_string))
);
$returndata = curl_exec ($ch);

print_r($returndata);

However, the server keep given empty response. I don't know if the server is available for public use like that. Is a authentication token required ?

zamir
  • 2,144
  • 1
  • 11
  • 23
David Lin
  • 13,168
  • 5
  • 46
  • 46