php - Send Headers during a curl call -


hi have send request api(pitney bowls geolocation) need access token site. in website mentioned - access token, set header , request body , call token uri:

authorization: basic {base64 encoded value}  content-type: application/x-www-form-urlencoded  post https://api.pitneybowes.com/oauth/token grant_type=client_credentials  

i using following code : -

$val= base64_encode ('{gr6ov7fcmuzhcvxe6bsmcuot3sxhmxll}:{ud61in4fysgyf0eu}');  $ch = curl_init(); $headr = array(); $headr[] = 'authorization: basic {'.$val.'}'; $headr[] = 'content-type: application/x-www-form-urlencoded'; $headr[]='grant_type=client_credentials'; curl_setopt($ch, curlopt_httpheader, $headr); curl_setopt($ch, curlopt_url, "https://api.pitneybowes.com/oauth/token"); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_ssl_verifyhost, false); curl_setopt($ch, curlopt_ssl_verifypeer, false); $response = curl_exec($ch);  curl_close($ch); 

however not getting result. idea might wrong?

the third header adding, not valid header.

you should add post key-value pair:

curl_setopt($ch, curlopt_postfields, 'grant_type=client_credentials'); 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -