Pregunta

I'm new to the Box API and especially Box API 2.0. After a few hours of working out the kinks of my cURL calls and all the rest of the code I finally got everything straightened out. Then the very next call that I made returned an HTML response that says -

Box Pardon the Pause Your Box account is temporarily down — but you shouldn't be — because we'll be up and running soon. Thanks for your patience ... and for being the most important part of Box.

Its been over an hour and I'm still getting this response, I tried waiting to see if it was some sort of throttling issue on my part, but I've only called the API probably 50 times or so since I started working 3-4 hours ago. Any thoughts/help?

$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);
¿Fue útil?

Solución

Result is this. I was calling the API wrong because of the way that Box expects the authorization parameters in the header. The correct way to make calls to the Box API is as follows :

    $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);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top