javascript - Recently, I was working on Lecheng's monitoring equipment. The first step of obtaining the accessToken through http post json failed. How to solve it?
为情所困
为情所困 2017-05-16 13:16:43
0
2
483

Website: Lecheng Application Development Guide


Now I can’t get the accessToken in the first step. My code is as follows:

function http_post_json($url, $jsonStr){
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonStr);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/json; charset=utf-8',
            'Content-Length: ' . strlen($jsonStr)
        )
    );

    $response = curl_exec($ch);
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
 
    return array($httpCode, $response);
}
 
$url = "https://openapi.lechange.cn:443/openapi/accessToken";
$jsonStr = json_encode(array('phone' => '18600000000'));
echo $jsonStr;
list($returnCode, $returnContent) = http_post_json($url, $jsonStr);

operation result:

为情所困
为情所困

reply all(2)
phpcn_u1582

I think your postfield should be this

$data = array(
    "params" => array(
        "phone" => "1xxxxxxxxxx"    
    ),    
);
習慣沉默

The data you uploaded is according to the manual,
$data = array(

"params" => array(
    "phone" => "1xxxxxxxxxx"    
),    

);
You can also ask customer service and try more

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template