Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send message from WhatsApp in PHP with WhatsAPI Official?

Tags:

php

whatsapp

I'm trying to use the WhatsApi Official library to send a message via WhatsApp from a php file. I've moved in my Apache web server the library, in a folder call test, like this:

enter image description here

The file whatsapp.php is this one:

    <?php
    require_once './src/whatsprot.class.php';
    $username = "1XXXXXXXXX";
    $password = "password";
    $w = new WhatsProt($username, "0", "My Nickname", true); //Name your application by replacing “WhatsApp Messaging”
    $w->connect();
    $w->loginWithPassword($password);
    $target = '1xxxxxxxxx'; //Target Phone,reciever phone
    $message = 'This is my messagge';
    $w->SendPresenceSubscription($target); //Let us first send presence to user
    $w->sendMessage($target,$message ); // Send Message
    echo "Message Sent Successfully";
?>

I'm facing some problem with the library new WhatsProt(), which blocks all the code (may be sockets ?).

So my question is, how can I fix this problem ? If no, are there any other solution to send message from a pho script ?

like image 345
I love coding Avatar asked Apr 16 '15 10:04

I love coding


People also ask

How do you send an official message on WhatsApp?

Texting with WhatsApp Tap the text bar at the bottom of the screen. Your keyboard will appear. Type the message you want to send, then tap the send button. Your message will be sent.

How can I use WhatsApp API for free?

How to get a free account. You can register your account via email, or you can sign in directly to app.chat-api.com using your Google Account or GitHub Account. You need to create a developer instance on the "Add new instance" page. A developer instance can only be a single instance on an account.


1 Answers

You can use below script to send message from whatsapp in PHP.

https://github.com/venomous0x/WhatsAPI/tree/master/examples

Configure the source code in Apache and run examples/whatsapp.php file.

You have change below configurations.

//simple password to view this script
$config['webpassword'] = 'MakeUpPassword';

and

$config['YOURNAME'] = array(
'id' => 'e807f1fcf82d132f9bb018ca6738a19f',
'fromNumber' => '441234567890',
'nick' => "YOURNICKNAME",
'waPassword' => "EsdfsawS+/ffdskjsdhwebdgxbs=",
'email' => '[email protected]',
'emailPassword' => 'gmailpassword'
);

It's working for me..

like image 142
Jayson Avatar answered Oct 06 '22 23:10

Jayson