相应地发布json数据

时间:2015-11-22 16:14:30

标签: php json

我的数据详情

POST /onlyearnapp/login.php HTTP/1.1
Content-Type: application/json; charset=utf-8
User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.4.4; Sparkle V Build/KPW77)
Host: www.onlyearn.in
Connection: Keep-Alive
Accept-Encoding: gzip
Content-Length: 75

我的Json输入名称和值

{"referredBy":"PQfkUUK","deviceId":"911400252849483","msisdn":"8358808909"}

这是我的PHP脚本编码,但是无法正常工作

set_time_limit(0);
error_reporting(0);
echo '
<html>
<head>
<style type=text/css>
option:first-child{
font-weight:bold;
}</style>
';
flush();
ob_flush();
date_default_timezone_set('Asia/Kolkata');




function n($length = 1) { // for number
    $str = "";
    $characters = range('0', '9');
    $max = count($characters) - 1;
    for ($i = 0;$i < $length;$i++) {
        $rand = mt_rand(0, $max);
        $str.= $characters[$rand];
    }
    return $str;
}
$imei = n(15);
$ckfile = tempnam("/tmp", "CURLCOOKIE");
$ch = curl_init();
$proxy = $_REQUEST['proxy'];
$brands = array("Micromax", "Xolo");
$rand_keys = array_rand($brands, 1);
$brand = $brands[$rand_keys];
$dalvikuseragents = array("Micromax" => "Dalvik/1.6.0 (Linux; U; Android 4.4.4; Sparkle V Build/JDQ39)", "Xolo" => "Dalvik/1.6.0 (Linux; U; Android 4.4.4; Sparkle V Build/KOT49H)");
$duseragent = $dalvikuseragents[$brand];
$headers[] = 'Accept: application/json;q=0.9,image/webp,*/*;q=0.8';
$headers[] = 'Accept-Encoding: gzip';
$headers[]='Accept-Charset: utf-8, *;q=0.7';

    $ch = curl_init();

    $url = "http://www.onlyearn.in/onlyearnapp/login.php";
    $post = "referredBy=PQfkUUK&deviceId=$imei&msisdn=8358808909";
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, "$duseragent");
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
 // curl_setopt($ch, CURLOPT_PROXY, $proxy);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $html = curl_exec($ch);
    echo "<br><br>$post<br><font color=green><b>" . htmlspecialchars("$html", ENT_QUOTES);
    echo "<br></font>";
  1. 这个脚本无法帮助我弄清楚我的编码
  2. 此外,我想回复我的输出,但它是说null

0 个答案:

没有答案