Translating cURL command to PHP -
i'm trying translate following curl command php.
curl -k https://api.box.com/2.0/files/content -h "authorization: bearer 8tuuimsrf3shyodvdw" -f filename=@txt.txt -f folder_id=0
here attempt:
$url = 'https://api.box.com/2.0/folders/content'; $params['filename'] = '@txt.txt'; $params['folder_id'] = '0'; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); 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); curl_setopt($ch, curlopt_httpheader, array("authorization: bearer ".$this->access_token, "content-type: multipart/form")); $data = curl_exec($ch); curl_close($ch);
it's not working however. can me understand why i'm doing wrong , can modify code? thanks!!
try getting rid of header "content-type: multipart/form"
curlopt_httpheader
option curl take care of based on post data.
since uploading file, content-type automatically set multipart/form-data
correct content type, not multipart/form
.
Comments
Post a Comment