因此,我一直在尝试集成Estimote API,将信标列表带到我的个人CMS中,我遇到了这样的问题:我在Api文档中看到了“未经授权”的消息,而通用授权是我能够做到的,因为我把云帐户中的信标带来了,在一个卷发请求上有一个例子,我可以通过这样做获得信标列表:
curl -u app_0a1b2c3d4e:0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d \
-H 'Accept: application/json' \
https://cloud.estimote.com/v1/beacons问题是我一直在尝试这样做,它说通常我应该使用App和App来授权我的请求
header('Content-Type: application/json');
$app_id = "appid";
$token = "token";
$ch = curl_init('https://cloud.estimote.com/v1/beacons?appid='.$appId.'&apptoken='.$token);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
$result = curl_exec($ch);
print_r($result);
curl_close($ch);对我做错了什么有什么想法吗?https://cloud.estimote.com/docs/#api-Beacons-GetBeacons
发布于 2016-03-19 07:34:06
您要做的是尝试发送带有get请求的post字段。
您可以删除这一行curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
在文档https://cloud.estimote.com/docs/#api-General-Authorization中,它指出您需要将appid作为用户名发送,令牌作为密码发送。卷曲中你有这个选择。
尝尝这个
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://cloud.estimote.com/v1/beacons');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$appid:$token");
$output = curl_exec($ch);
curl_close($ch);https://stackoverflow.com/questions/36099060
复制相似问题