Closed honggianto closed 3 years ago
hi, try this
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://localhost:8002/sendText",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"args": {
"to": "00000000000@c.us or 00000000000-111111111@g.us",
"content": "Hello World!"
}
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Awesome! It works! Thank you so much @smashah ...
Here's another script that worked too in PHP version 8 :
<?php
$url = 'http://localhost:8002/sendText';
$data = array("args" => array ("to" => "000000000@c.us" ,"content" => "Wonderful!" ) );
$postdata = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$result = curl_exec($ch);
curl_close($ch);
print_r ($result);
Hi all,
I tried to /sendText using PHP script below :
and the result always :
{"success":true,"response":"Message missing"}
What am i missed here ? Help me please... Thanks before.