Hi,
I have used Rest API OAuth 1a to create a new leads.
http://develop.fashionlearn.me/allprojectthorughajax
after authenticating the app,it redirecting to my following callback url ,
http://develop.fashionlearn.me/createleads?oauth_token=bloq464byhsk4888s84c04o4cos804kkskc8c8o0ko0kggc0c&oauth_verifier=1fex3sv652tc84kg804cok8g4s044scw80so0owwow0ggwo00
i have written the code here to create a new leads,but it showing me 404 from mautic on my page.
$id=$_GET[“oauth_verifier”];
$curl = curl_init();
$data = array(
‘firstname’ => ‘Joce’,
‘lastname’ => ‘Nuunes’,
‘email’ => ‘jocenunes@fashionlearn.com.br’,
‘ipAddress’ => $_SERVER,
‘owner’=>$id
);
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => ‘http://162.243.61.31/leads/2899’,
CURLOPT_USERAGENT => ‘Codular Sample cURL Request’,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $data
));
$resp = curl_exec($curl);
curl_close($curl);
Hi,
I have used Rest API OAuth 1a to create a new leads.
http://develop.fashionlearn.me/allprojectthorughajax
after authenticating the app,it redirecting to my following callback url ,
i have written the code here to create a new leads,but it showing me 404 from mautic on my page.
$id=$_GET["oauth_verifier"];
$curl = curl_init();
$data = array(
'firstname' => 'Joce',
'lastname' => 'Nuunes',
'email' => 'jocenunes@fashionlearn.com.br',
'ipAddress' => $_SERVER['REMOTE_ADDR'],
'owner'=>$id
);
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => ‘http://162.243.61.31/leads/2899’,
CURLOPT_USERAGENT => ‘Codular Sample cURL Request’,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $data
));
$resp = curl_exec($curl);
curl_close($curl);
I don’t see the OAuth access token used anywhere in your code. Please, use https://github.com/mautic/api-library
I just modified the code,
public function createleadsAction(){
$id=$_GET["oauth_verifier"];
$outh=$this->view->session->storage->outh_access_token;
$objmautic=Engine_mautic_lib_MauticApi::getinstance();
$outhnouns=rand(100000,999999);
if($id){
// urlencode(‘oauth_callback’)=urlencode(“http%3A%2F%2Fdevelop.fashionlearn.me%2Fallprojectthorughajax”)&urlencode(‘oauth_consumer_key’) = urlencode(“66aajqqqq9s04wk888ws0c4s0k8k0sc0soc0wkk88s04cg80s8”)&urlencode(‘oauth_signature_method’) = urlencode(“HMAC-SHA1”)&urlencode(‘oauth_timestamp’) = urlencode(time()) &urlencode(‘oauth_version’) = urlencode(‘1.0’)&urlencode(‘oauth_nonce’)= urlencode(‘0678’));
$fields =array(
'oauth_callback' => "https%3A%2F%2Fdevelop.fashionlearn.me%2Fcreateleads",
'oauth_consumer_key' => "rgri60y4ipcos04848okosw8o4kwcwwckg8484kcokkg4k4s",
'oauth_nonce'=>$outhnouns,
'oauth_signature_method' => "HMAC-SHA1",
'oauth_timestamp' => time(),
'oauth_token'=>$outh,
'oauth_version' => '1.0',
'oauth_verifier'=>$id,
'firstname' => 'Jim',
'lastname' => 'Lead',
'email' => 'jim@his-site.com',
'ipAddress' => $_SERVER['REMOTE_ADDR'],
'lastActive'=>$date = date('m/d/Y h:i:s a', time()),
'owner'=>''
);
$signature=$objmautic->signature(“POST”,“http://marketing.fashionlearn.com.br/api/leads/new",$fields,"5zw2o0kkut8g8gs8os0k4wogs8044swk88oso4c44kwwwswc0s”);
// $this->_helper->layout()->disableLayout();
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => ‘http://marketing.fashionlearn.com.br/api/leads/new’,
CURLOPT_USERAGENT => ‘Codular Sample cURL Request’,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => array(
‘oauth_callback’ => “https%3A%2F%2Fdevelop.fashionlearn.me%2Fcreateleads”,
‘oauth_consumer_key’ => “rgri60y4ipcos04848okosw8o4kwcwwckg8484kcokkg4k4s”,
‘oauth_nonce’=>$outhnouns,
’ oauth_signature’=>$signature,
‘oauth_signature_method’ => “HMAC-SHA1”,
‘oauth_timestamp’ => time(),
‘oauth_token’=>$outh,
‘oauth_version’ => ‘1.0’,
‘oauth_verifier’=>$id,
‘firstname’ => ‘Jim’,
‘lastname’ => ‘Lead’,
‘email’ => ‘jim@his-site.com’,
‘ipAddress’ => $_SERVER[‘REMOTE_ADDR’],
‘lastActive’=>$date = date(‘m/d/Y h:i:s a’, time()),
‘owner’=>’’
)
));
$resp = curl_exec($curl);
curl_close($curl);
echo $resp; die;
}
else{
echo “leads created”;die;
}
}
this is the callback function after authentication,
i am getting 401 now
{“error”:{“message”:“token_rejected”,“code”:401}}
I’m sorry, I’ve never tried it with raw CURL calls like that.
That’s okay,
But please check the values i am setting in header and with post data.
I am retrieving the access token from session,so i don’t think it should say unauthorized access token 401.
also can you please tell me how to deauthorize the app ?
I don’t have experience with the CURL code. I’m not sure how the token gets stored in the session. Maybe you should consider to use the Mautic API library to make your life easier. An app can be unauthorized if you remove the API credentials from Mautic.
If I click on the link above, I see this:
Notice: Trying to get property of non-object in /var/www/develop.fashionlearn/application/modules/teach/controllers/TeachController.php on line 4877
{"error":{"message":"parameter_absent","code":400}}