javascript - 最近在做樂橙的監控設備,第一步透過http post json取得accessToken都失敗了,請問如何解決?
为情所困
为情所困 2017-05-16 13:16:43
0
2
438

網址:樂橙應用程式開發指南


現在我第一步的取得accessToken都取得不到,我的程式碼如下:

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);

運行結果:

为情所困
为情所困

全部回覆(2)
phpcn_u1582

我認為你postfield應該是這個

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

你這個上傳的數據,按照手冊上的來,
$data = array(

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

);
也可以問一下客服,多試試

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!