We are implementing the Orange business apps API. For this, we need to call an Orange service. This service has Bearer type authentication (Oauth2). I am able to get access token successfully and access token validity is 90 days. By using latest access token, I tried to call an Orange service by sending the access token in header but getting unauthorized access error every time.
Here is code
public static function sendEventProductOrder($eventProductOrdering) {
$jsonMapper = new JsonMapper();
$opts = array('http' => array('method'=>'POST',
'header'=>'Content-type: application/x-www-form-urlencoded\r\n'.'Authorization: Bearer xxxxxxxxxxxxxxxxx\r\n',
'content' => json_encode($jsonMapper->unmap($eventProductOrdering)),
));
$context = stream_context_create($opts);
if (($stream = fopen("https://api.orange.com/mba/productordering/v2/event", 'r', false, $context)) !== false) {
$content = stream_get_contents($stream);
$header = stream_get_meta_data($stream);
fclose($stream);
return HelperMisc::isEqualIgnoreCase($header['wrapper_data']['0'], 'HTTP/1.1 201 Created');
}
return false;
}
Can any one help me in this?
Thank you for your help!