I am developing a plugin in some php framework.From which i need to integrate mautic and get the certain data from mautic with this plugin.I have read the developer documentation of mautic, i have installed mautic locally and i am unable to authenticate with oauth1a also with basic authentication. My basic authentication code redirects me to login page and in case of oath1a it is giving me the error Unauthorized access to URL.
Here is my code for basic authentication :
<?php
$login = 'admin';
$password = '123456';
$url = 'http://127.0.0.1/mautic/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
"Authorization: Basic " . base64_encode($login . ":" . $password)
));
//curl_setopt($ch, CURLOPT_USERPWD, "$login:$password");
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$result = curl_exec($ch);
print_r(curl_exec($ch));
curl_close($ch);
//echo($result);
And through oath1a the code is
<?php
$url = 'http://127.0.0.1/mautic/oauth/v1/request_token';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array(
'Authorization:
OAuth oauth_callback="http%3A%2F%2F127.0.0.1%2Fmautic%2Fs%2Fcontacts",
oauth_consumer_key="1o1tl7zmuatcwkcw0k84wo0wgwsow4kwsgskwow044g0s0soow",
oauth_nonce="4dp2mp6v86qsgc4844ksskkkw8k4s8ksg4gos84g84osookcgw",
oauth_signature="GENERATED_REQUEST_SIGNATURE",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1318467427",
oauth_version="1.0"'
));
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$result = curl_exec($ch);
print_r($result);
//print_r(curl_exec($ch));
curl_close($ch);
And this oath is giving me error
{
"error": {
"message": "Unauthorized access to requested URL: /mautic/oauth/v1/request_token",
"code": 403
}
}