translating curl request to php -
i trying use , api, curl request below works on command line:
curl 'https://subdomain.test.domain.com/api/v1/users/4508184' -x put -f 'user[avatar][url]= http://domain.com/canvas/avatar.jpg' -h "authorization: bearer tokenxxxxxxxxyyyyyyy" here have translated code above php, although request being sent not working because says "token invalid". 100% sure token working , correct presume there in code
$curl = curl_init(); curl_setopt_array($curl, array( curlopt_url => "{$baseurl}{$userid}", curlopt_customrequest => 'put', // -x curlopt_postfields => 'user[avatar][url]=http://domain/canvas/avatar.jpg', // -f curlopt_httpheader => $header // -h )); $result = curl_exec($curl); curl_close($curl); thank you
saw in $header (single quotes) work:
$header = "authorization: bearer tokenxxxxxyyyyy"; $curl = curl_init(); curl_setopt_array($curl, array( curlopt_url => "{$baseurl}{$userid}", curlopt_customrequest => 'put', // -x curlopt_postfields => 'user[avatar][url]=http://domain/canvas/avatar.jpg', // -f curlopt_httpheader => $header // -h )); $result = curl_exec($curl); curl_close($curl);
Comments
Post a Comment