PHP cURL - authorization token missing -


i trying curl apptweak (ref - https://apptweak.io/api )

curl -h 'x-apptweak-key: your-api-key' https://api.apptweak.com/ios/applications/284882215.json 

i have key , can curl terminal. in php, "authorization token missing".

$curl = curl_init(); curl_setopt_array($curl, array(     curlopt_returntransfer => 1,     curlopt_url => 'https://api.apptweak.com/ios/applications/284882215.json&country=us&language=en',     curlopt_post => 1,     curlopt_postfields => array(     x-apptweak-key => 'my-key-is-here'     ) )); $resp = curl_exec($curl);  print $resp; curl_close($curl); 

is x-apptweak-key => 'my-key-is-here' being post field issue here?

what wrong?

you can add x-apptweak-key between single quotes it's key

curlopt_postfields => array(    'x-apptweak-key' => 'my-key-is-here'     ) 

or can try this:

curl_setopt($ch, curlopt_httpheader, array('content-type: application/json; charset=utf-8',         'authorization: basic my-key-is-here')); 

or can use:

curl_setopt($ch, curlopt_userpwd, "x-apptweak-key:my-key-is-here"); 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -