Skip to main content

Here is demo for curl for rest using token.
Token you need to generate from admin System->Integration and configure in code below.
For demo purpose I have made below rest default customer call.

error_reporting(E_ALL);
ini_set('display_errors', 1);
/*Token Generated from SYstem Integration*/ $token = '4hmpioj8qvtgh1d06ujgg52a52yqbmye' (This is token generated from system integration);
$rest_url = 'http://localhost/magentoce27/index.php/rest/V1/customers/1';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$rest_url);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer '.$token;
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec ($curl);
echo ""; print_r($result);
?>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

/*Token Generated from SYstem Integration*/

$token = '4hmpioj8qvtgh1d06ujgg52a52yqbmye' (This is token generated from system integration);
$rest_url = 'http://localhost/magentoce27/index.php/rest/V1/customers/1';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$rest_url);

$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer '.$token;

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec ($curl);

echo "<pre>"; print_r($result);
?>

Here is demo for curl for rest using token.
Token you need to generate from admin System->Integration and configure in code below.
For demo purpose I have made below rest default customer call.

error_reporting(E_ALL);
ini_set('display_errors', 1);
/*Token Generated from SYstem Integration*/ $token = '4hmpioj8qvtgh1d06ujgg52a52yqbmye' (This is token generated from system integration);
$rest_url = 'http://localhost/magentoce27/index.php/rest/V1/customers/1';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$rest_url);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer '.$token;
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec ($curl);
echo ""; print_r($result);
?>

Here is demo for curl for rest using token.
Token you need to generate from admin System->Integration and configure in code below.
For demo purpose I have made below rest default customer call.

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

/*Token Generated from SYstem Integration*/

$token = '4hmpioj8qvtgh1d06ujgg52a52yqbmye' (This is token generated from system integration);
$rest_url = 'http://localhost/magentoce27/index.php/rest/V1/customers/1';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$rest_url);

$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer '.$token;

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec ($curl);

echo "<pre>"; print_r($result);
?>
Source Link
Rushvi
  • 2.8k
  • 2
  • 15
  • 31

Here is demo for curl for rest using token.
Token you need to generate from admin System->Integration and configure in code below.
For demo purpose I have made below rest default customer call.

error_reporting(E_ALL);
ini_set('display_errors', 1);
/*Token Generated from SYstem Integration*/ $token = '4hmpioj8qvtgh1d06ujgg52a52yqbmye' (This is token generated from system integration);
$rest_url = 'http://localhost/magentoce27/index.php/rest/V1/customers/1';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,$rest_url);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Bearer '.$token;
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec ($curl);
echo ""; print_r($result);
?>