我是Box API的新手,特别是Box API 2.0。经过几个小时的解决我的cURL调用和所有其余代码的问题后,我终于彻底解决了所有问题。然后,我做的下一次调用返回了一个HTML响应,上面写着 -
盒子原谅Pause 您的Box帐户暂时关闭 - 但您不应该 - 因为我们很快就会启动并运行。 感谢您的耐心......以及成为Box最重要的部分。它已经超过一个小时了,我仍然得到这个回应,我试着等着看我是否有某种节流问题,但是自从我开始以来我只调用了API大概50次左右工作3-4小时前。有什么想法/帮助吗?
$url = "https://api.box.com/2.0/folders/0";
$headers[] = "Authorization: BoxAuth api_key=$key,auth_token=$token";
//curl https://api.box.com/2.0/folders/FOLDER_ID \
//-H "Authorization: BoxAuth api_key=API_KEY&auth_token=AUTH_TOKEN"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, "CURL_HTTP_VERSION_1_1");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
答案 0 :(得分:0)
结果就是这样。我之所以调用API是错误的,因为Box期望标头中的授权参数。调用Box API的正确方法如下:
$key = $box["API_Key"];
$token = $box["Auth_Token"];
$url = "https://api.box.com/2.0/folders/" . "0";
$headers[] = "Authorization: BoxAuth api_key=$key&auth_token=$token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTP_VERSION, "CURL_HTTP_VERSION_1_1");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLINFO_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);