php微信公众平台开发API接口连接的问题,求帮忙!
本人申请了一个微信公众平台订阅号,把新浪云作为服务器编写代码,现在公众平台想要有一个实时传输监控视频的功能,所以申请了一个叫做萤石云的视频云平台,现在遇到不知怎么把萤石云的数据传送到新浪云,下面代码运行后,并没有成功获取相应的东西,数据为json格式的。
图为萤石云提供的开发者接口文档
我的代码:
case"视频":
//获得服务器时间time
$data='{ "id":123456",
"appKey" :"116622259fed4920a3e8957e13dc2346"
}';
$url="https://open.ys7.com/api/time/get";
$ch = curl_init( $url); //请求的URL地址
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//$data JSON类型字符串
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data)));
$data = curl_exec($ch);
if (curl_errno($curl)) {
return 'Errno'.curl_error($curl);
}
curl_close($curl);
$final = json_decode($data);
$time= $final->serverTime;
$results= $final->code;
if($results=="200")
{
//获得服务器access_token
$jsondata='{
"id":"123456",
"system": {
"key": "116622259fed4920a3e8957e13dc2346",
"sign": "8845c7ad6066c9cf1df170afd7dd5f06",
"time": $time,
"ver": "1.0"
},
"method":"token/accessToken/get",
"params": {
"userId": "3256987",
"phone" :"13588996397"
}
}';
$ur1 ="https://open.ys7.com/api/method";
$ch = curl_init( $url); //请求的URL地址
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsondata);// $jsondata JSON类型字符串
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen( $jsondata)));
$jsondata = curl_exec($ch);
if (curl_errno($curl)) {
return 'Errno'.curl_error($curl);
}
curl_close($curl);
$final1 = json_decode($jsondata);
$Access_token = $final1->access_token;
$results1= $final1->code;
if($results1=="200")
{
//获取设备的视频
$jsondata1='{
"id": "123456",
"system": {
"key": "116622259fed4920a3e8957e13dc2346",
"sign": "8845c7ad6066c9cf1df170afd7dd5f06",
"time": $time,
"ver": "1.0"
},
"method": " camera/getCameraInfo",
"params": {
"accessToken" : $Access_token,
"deviceSerial" : "325698712"
}
}';
$url ="https://open.ys7.com/api/method";
$ch = curl_init( $url); //请求的URL地址
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsondata1);// $jsondata1 JSON类型字符串
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen( $jsondata1)));
$jsondata1 = curl_exec($ch);
if (curl_errno($curl)) {
return 'Errno'.curl_error($curl);
}
curl_close($curl);
$final1 = json_decode($jsondata1);
}
}
return $final1;
Break;
本人新手,希望各位能帮忙指教,找出正确调用的方法!!