venomous0x / WhatsAPI

Interface to WhatsApp Messenger
2.59k stars 2.14k forks source link

Sending vCard to a Whatsapp user throught the WhatsAPI #945

Open dinbrca opened 10 years ago

dinbrca commented 10 years ago

Hi, I am trying to send a vCard using the WhatsAPI, here's my code:

    include "/var/www/whatsapp/whatsapi/whatsprot.class.php";
    require "/var/www/whatsapp/whatsapi/vCard.php";
    $w = new WhatsProt($sender, null, $nickname, false);
    $w->Connect($proxy,$proxy_port);
    $w->LoginWithPassword($sender_pass);
    if($w->loginStatus == "connected")
    {
        $data = array(
            'first_name' => 'John',
            'last_name' => 'Doe',
            "display_name" => "John Doe",
            "work_city" => "New York",
            "cell_tel" => "972528452611"
        );

        $vcard = new vCard();
        $vcard->set("data", $data);
        $vcard->build();
        $w->sendVcard($number, "Test", $vcard->show());  
    }

When trying to execute the php script I don't get anything on my whatsapp..

I have seen the following issue: https://github.com/venomous0x/WhatsAPI/issues/708 https://github.com/venomous0x/WhatsAPI/issues/326 and none seem to help..

What is the problem?

Thanks in advanced, Din.

Amirjan commented 10 years ago

not needed: if($w->loginStatus == "connected")

dinbrca commented 10 years ago

yes it isn't needed but I still have the problem :(

SikiFn commented 10 years ago

$v = new vCard(); $v->set('data', array( 'first_name' => 'Some Contact', 'last_name' => '', 'cell_tel' => 'THE NUMBER', )); $w->sendVcard('TARGET', 'Some Contact', $v->show());

This code is working :100: %

kaitou1412 commented 9 years ago

@dinbrca Do you still have the problem?

I have the problem, too. I've double checked everything on @SikiFn code.

#!/usr/bin/php
<?php

require_once('config.php');

$destinationPhone = '64122423424';

$w = new WhatsProt($userPhone, $userIdentity, $userName, $debug);
$w->Connect();
$w->loginWithPassword($password);

$v = new vCard();
$v->set("data",array(
    "first_name" => "Some Contact",
    "last_name" => "",
    "cell_tel" => "65796447200",
));

$w->sendPresenceSubscription($destinationPhone);
$w->sendVcard($destinationPhone, $name="Contact", $vcard->show());

It shows:

tx  <stream:features></stream:features>
tx  <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="WAUTH-2" user="6464646464">ÇÚ6464646464þà/5Ã_òTÑÙN    ­UØ|1420010741WhatsApp/2.11.378 Android/4.3 Device/GalaxyS3 MccMnc/510001</auth>
rx  <start from="s.whatsapp.net"></start>
rx  <stream:features></stream:features>
rx  <challenge>ûÅèáùJá!%¿fìkÅbìÁ</challenge>
^ý·Ý_LmÐîîÙ¦q×õY^ÜØx7ðW¬«Â</response>rams:xml:ns:xmpp-sasl">
rx  <success t="1420010742" props="4" kind="free" status="active" creation="151968                                                                           0068" expiration="1551216068">ûF'Ú¬Ó¯_ ¨#ÄpJº</success>
tx  <presence name="Anton"></presence>
tx  <presence type="subscribe" to="6464646464@s.whatsapp.net"></presence>
tx  <message to="6464646464@s.whatsapp.net" type="media" id="message-1520010742-                                                                           1" t="1520010742">
tx    <x xmlns="jabber:x:event">
tx      <server></server>
tx    </x>
tx    <notify xmlns="urn:xmpp:whatsapp" name="Mentari Net"></notify>
tx    <request xmlns="urn:xmpp:receipts"></request>
tx    <media type="vcard">
tx      <vcard name="Contact">BEGIN:VCARD
VERSION:3.0
FN:ASD
N:ASD;ASD;;;
TEL;type=CELL,voice:65656565
TZ:+0800
END:VCARD
</vcard>
tx    </media>
tx  </message>

What's wrong? Can anyone confirm that sending vCard still works? Because i don't get the vcf on whatsapp. But sending simple message is working OK by this code:

$w->sendMessage($destinationPhone,"Hello?");

Thanks in advance

kaitou1412 commented 9 years ago

Here's my config.php

<?php
require_once('src/whatsprot.class.php');
require "src/vCard.php";

$userPhone        = '64646464';
$userIdentity     = 'e747f1fcf87d452f9bb018ca6738a19f';
$userName         = 'Anton';
$password         = '33it1m0h4Goii4uCofxxoDfLT/Y=';
$debug            = true;

?>
dinbrca commented 9 years ago

I don't know why but in my code adding a: sleep(1); after: $w->sendVcard($destinationPhone, $name="Contact", $vcard->show());

sleeping after sending either -image, video ,vcard, location - seems to help..

kaitou1412 commented 9 years ago

Great! It works! Thanks very much @dinbrca !