u013256232
消弭的小米
2017-04-10 13:55

大华乐橙监控设备如何开发?

下载了乐橙开发者中心的web端的SDK,然后注册了开发者中心,现在获取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/accessToken";
$jsonStr = json_encode(array('phone' => '18600000000'));
echo $jsonStr;
list($returnCode, $returnContent) = http_post_json($url, $jsonStr);
var_dump($returnCode);
var_dump($returnContent);
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

相关推荐