UPD: Noticied some errors in official (docs).
Code to make request via curl in documentation:
$ch = curl_init();
$header = array(
'Content-type: application/vnd.api+json',
'Accept: application/vnd.api+json',` //SYNTAX 1
);
$postStr = json_encode(array(
'grant_type' => 'client_credentials',
'client_id' => '3D7f3fda97-d8e2-b9ad-eb89-5a2fe9b07650',
'client_secret' => 'client_secret',
'scope' => 'standard:create standard:read standard:update standard:delete standard:delete standard:relationship:create standard:relationship:read standard:relationship:update standard:relationship:delete'
));
$url = 'https://path-to-instance/api/oauth/access_token';
curl_setopt($ch, CURLOPT_URL, url); //SYNTAX 2
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$output = curl_exec($ch);
As u can see, we have 2 errors:
- Line 4 - Symbol "
" at end - [strike]'Accept: application/vnd.api+json',
[/strike] - variale βurlβ wrote without β$β - [strike]curl_setopt($ch, CURLOPT_URL, url)[/strike]
When I rewrite to code above I have new 404 error :cheer:
βThe requested URL /crm/lib/API/public/index.php/oauth/access_token was not found on this server.β
$ch = curl_init();
$header = array(
'Content-type: application/vnd.api+json',
'Accept: application/vnd.api+json',
);
$postStr = json_encode(array(
'grant_type' => 'client_credentials',
'client_id' => '3D7f3fda97-d8e2-b9ad-eb89-5a2fe9b07650',
'client_secret' => 'client_secret',
'scope' => 'standard:create standard:read standard:update standard:delete standard:delete standard:relationship:create standard:relationship:read standard:relationship:update standard:relationship:delete'
));
$url = 'https://luckwheel.ru/crm/api/oauth/access_token';
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$output = curl_exec($ch);