pranavms13 / whatsapp-node-api

A Simple NodeJS API Wrapper for WhatsApp
Other
471 stars 184 forks source link

please enter valid phone and message #28

Closed alibh92 closed 3 years ago

alibh92 commented 3 years ago

Hello,

I am trying to make sending messages , but it is telling: please enter valid phone and message . I don't think the issue with the number as it is going through GET. Somehow I think the issue is with the message as it is going through POST.

Below is the code with PHP , please correct me if I am wrong with something.

$data = array('message'=>'test message');
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:5000/chat/sendmessage/98666669421");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$reply=curl_exec($ch);
curl_close($ch);
echo $reply;

Any help with this?

Looking forward

alibh92 commented 3 years ago

@pranavms13 kindly help with thanks :)

pranavms13 commented 3 years ago

I think you have the wrong phone number. Please check it @alibh92

alibh92 commented 3 years ago

Hi. @pranavms13 The issues is not with the number. I just write fake number in the code above. I just changed the message variable from POST to GET and the issues was solved. Something is related to POST message is stopping the above code to work. I just solved it temporarily by making the message to be GET not POST.