rest - Oauth2 PHP no data returned -


i have trouble getting access token from:

api.hybrid.ru/token

documentation api in russian (link) , says:

headers post /token http/1.1 host: api.hybrid.ru content-type: application/x-www-form-urlencoded  data: grant_type=client_credentials&client_id={client_id}&client_secret={client_secret} 

i have valid client_id , client_secret (hybrid.ru techs gave me those), won't return error message. use curl , there goes code:

<?php   error_reporting(e_all); ini_set('display_errors',1);  $ch = curl_init();  $url = "https://www.api.hybrid.ru/token";   $post_data = array( 'grant_type'=> 'client_credentials', 'client_id'=>'********', 'client_secret'=>'********' );   curl_setopt($ch, curlopt_httpheader, array( "post /token http/1.1", 'content-type: application/x-www-form-urlencoded', "host: api.hybrid.ru" ));  curl_setopt($ch, curlopt_url, $url);  curl_setopt($ch, curlopt_returntransfer,1);  curl_setopt($ch, curlopt_followlocation, 1);  curl_setopt($ch, curlopt_customrequest, "post");  curl_setopt($ch,curlopt_postfields, $post_data);  curl_setopt($ch, curlopt_postredir, 3);  $output = curl_exec($ch);  curl_close($ch);  print_r($output);  ?> 

i thought, if there errors in client_id or client_secret api should return error message @ least.

and 1 more question, can client_secret contain character "="? gave me client_secret trailing "=" sign. anyways, or without character doesn't return data.

any help?

update 1

after following lorna mitchell's answer, messages:

array (  [url] => https://api.hybrid.ru/views/errors/defaulterror.cshtml?aspxerrorpath=/  [content_type] => text/html; charset=utf-8 [http_code] => 500 [header_size] => 483  [request_size] => 440  [filetime] => -1  [ssl_verify_result] => 0  [redirect_count] => 1  [total_time] => 3.853833  [namelookup_time] => 0.972059  [connect_time] => 1.178887  [pretransfer_time] => 1.406303  [size_upload] => 479  [size_download] => 1763  [speed_download] => 457  [speed_upload] => 124  [download_content_length] => 1763  [upload_content_length] => 479  [starttransfer_time] => 1.612792 [redirect_time] => 2.028607  [redirect_url] =>  [primary_ip] => 212.8.236.42  [certinfo] => array ( )  [primary_port] => 443  [local_ip] => 162.214.7.244  [local_port] => 46088  )  http/1.1 100 continue http/1.1  302 found  date: wed, 26 jul 2017 16:47:47 gmt  content-length: 166  connection: keep-alive  location: /views/errors/defaulterror.cshtml?aspxerrorpath=/  server: hybrid web server http/1.1 100 continue http/1.1 500 internal server                         error  date: wed, 26 jul 2017 16:47:49 gmt  content-type: text/html; charset=utf-8  content-length: 1763  connection: keep-alive  cache-control: private  x-aspnet-version: 4.0.30319  server: hybrid web server 

any idea after those?

does curl_error($ch) return useful information?

check curlopt_httpheader being set, , remove except content type (the other pieces here aren't headers, example docs showing how request should when sent).

you can check code sending using tool http://requestb.in. go there, create new bin, , use url in code. you'll able inspect code sending , check correct.

if looks right, api you're trying integrate has bug :(


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -