Hi, I have an API link http://mydomain.com/api/Getalllead. Data is coming through the link in JSON format. I want to insert these data into my lead module.
Hi,
Basically you have to decide if your third party application triggers the request or if Suite should pull every x minutes/hours/days.
In case your 3rd party application does the request, have a look at the API description here (v4).
Otherwise, if Suite has to pull in a specific intervall, you could do it as scheduled job.
This is my code but i’m getting error…i.e., Fatal error : Uncaught Error: Class ‘BeanFactory’ not found in C:\xampp\htdocs\suitcrm\Api\Hit\addlead.php:28 Stack trace: #0 {main} thrown in C:\xampp\htdocs\suitcrm\Api\Hit\addlead.php on line 28
<?php
$api_url = "http://localhost/xonieruat/api/Getalllead";
$client = curl_init($api_url);
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($client);
$result = json_decode($response);
// $output = '';
if(count($result) > 0)
{
foreach($result as $row)
{
$id=$row->id;
$name=$row->name;
$phone=$row->phone_number;
$bean = BeanFactory::newBean("leads");
$bean->first_name = 'Ravi';
$bean->last_name ='Gupta';
$sugar_case_id = $bean->save();
}
}
else
{
echo "No data found";
}
?>
Hi,
am I right that you’d like to run script repetitively? In this case, follow the tutorial described in the 2nd link.
The problem with your file: it is not integrated in the framework, that’s why the class definition can’t be found.
E: Btw I’ve added a code block around your php lines for better readability.