About BOX API file download

SOLVED
Go to solution
Highlighted
Occasional Contributor

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)

 

1 REPLY 1
Highlighted
Occasional Contributor

Re: About BOX API file download

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)