This topic is locked

how to create and use webhooks in phprunner

2/20/2023 1:36:39 PM
PHPRunner General questions
DRISS author

i would lilke to use the webhooks , could you plase help

admin 2/20/2023

You need to provide more info, it is not very descriptive.
What kind of webhooks, why do you need PHPRunner to create webhooks etc.

J
John 2/20/2023

Driss: You might want to consider this basic info on webhooks..
https://www.formstack.com/resources/blog-webhook-vs-api
Also, generally it is good ideal to include in this forum what exactly you are trying to accomplish and what you have done...
Regards..
J

DRISS author 2/21/2023

Hi ,
here the detail of customer needs .
i have a customer in the industrial field producing a metal product and have an application for production management so when he receive a part from his supplier with defect or any noncoformity he want to send a message immedialtly to the IT system of his supplier so he can take the corrective actions immedialtly , the production is in juste in time process .
the application of the supplier is the same then the customer developped by phprunner .
is webhooks a solution ?( emitter custom (json data) and the supplier receiver ).
thks

I
IKA9 2/22/2023

salam All , webhook is good for automation , since ur issue is just inform supplier with issue on product u can just add email script on event send email if condition is met .
for more details .
u want to send details as email ? to chat egg telegram group ? slack group ? .

fhumanes 2/22/2023

Hello,
If I were in your situation, I would solve it with Restifull API.
I would use this form to integrate the server (application of the supplier, use of Slim): https://fhumanes.com/blog/integracion/app-phprunner-con-restfull-api/
And would use this other way to communicate any incident from the application of the client (use of UNIREST). https://fhumanes.com/blog/integracion/app-phprunner-cliente-restfull-api/
Greetings,
fernando

G
guimafx 2/25/2023

What you mean, send to another endpoint ?
Inside class eventsBase{} @ events.php you can Add some REST
` public function SendInfoToAnotherPlace($obj)
{
$url = "<a href='https://xxxxxxxmydomain.com/receive/post'>https://xxxxxxxmydomain.com/receive/post</a>;";

$myInfo['script'] = $_SERVER['SCRIPT_FILENAME'];
$myInfo['obj'] = $obj;

$content = serialize($myInfo);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resposta = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 200 ) {

die("Was not possible to send "");
}

curl_close($curl);

}
AND AFFTER THE RECORD IS INSERT @ PHPRUNNER EVENTS....
You just declare

$this->SendInfoToAnotherPlace($pageObject);
With that, you can comunicate with other services...sendind what you whant or need`

DRISS author 2/25/2023

thanks for your help