Hello Everyone,
I am trying to implement Box file upload in php curl method. But its not working, i am not getting any response from Box file Api. Following is my curl method code. Can anybody please look into this issue and share your idea to resolve this issue.
$url = 'https://upload.box.com/api/2.0/files/content';
$attributes = array('name' => $file->filename, 'parent' => array('id' => '***number removed for privacy***47'));
$params = array('attributes' => json_encode($attributes), 'file' => "@".drupal_realpath($file->uri));
$headers = array("Authorization: Bearer ".$res_data['access_token']);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch);
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$errNo = curl_errno($ch);
$errStr = curl_error($ch);
curl_close($ch);
Note: i am getting only the curl response code 400.
Thanks,
VijeeshCiber
