About BOX API file download
回答済みI want to download files using BOX API and PHP curl library.
I ran the following program, but the response of BOX API is returned as null.
I want to know the cause.
//----------------------------------------------------------------------------------------------------------------------------
// PHP Version 7.4.6
// file_url == https://app.box.com/master/content/9999999/88888888/0/12341234
//----------------------------------------------------------------------------------------------------------------------------
$dl_api ='https://api.box.com/2.0/files/12341234/content';
$header = array("Authorization: Bearer {'access_token'}", "Content-Type: application/json");
$curl = curl_init($dl_api);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl)
-
I understood the cause
An unnecessary setting was included in the option setting of the curl library.
// Mistake part
$curl = curl_init($dl_api);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);$response = curl_exec($curl)
// Modified part
$curl = curl_init($dl_api);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');$response = curl_exec($curl)
サインインしてコメントを残してください。
コメント
1件のコメント