GithubHelp home page GithubHelp logo

whatsapp-tools's Introduction

WhatsApp Tools

Contact with me: me [at] mgp25.com or @_mgp25


Instrucciones y líneas básicas

whatsprot.class.php is required almost for all scripts (Telling this for beginners...)

Registering a new number / Registrando un nuevo numero

  $debug = true;

  $username = '34666554433'; // Telephone number including the country code without '+' or '00'.
  $identity = ''; 
  $nickname = 'WA Tools'; // This is the username displayed by WhatsApp clients.


  // Create a instance of WhastPort.
  $w = new WhatsProt($username, $identity, $nickname, $debug);
  
  $w->codeRequest('sms');

Once you have the code similar to 123-456. You have to insert it this way 123456. Update the script to validate your code with:

  $w->codeRegister('123456'); 

Logging in / Iniciando sesión

 $username = ''; // Number with country code
 $password = ''; // Password obtained with WART or WhatsAPI
 $identity = ''; // $identity is no longer necessary
 $debug = false; // You can set true, for more details

 $nickname = "WA Tools"; // This is the username (or nickname) displayed by WhatsApp clients.
  

$w = new WhatsProt($username, $identity, $nickname, $debug);
$w->connect();

// Now loginWithPassword function sends Nickname and (Available) Presence
$w->loginWithPassword($password);

Sending Messages / Enviando mensajes

  $dst = '34666554433'; // The number of the person you are sending the message

  $w->sendMessage($dst , "Este es un mensaje de prueba :D");
  
  // You can also add a $message and use it this way:
  $w->sendMessage($dst , $message);

Requesting Last Seen / Viendo la última vez en linea

 $msgid = time()."-1";

//The function retrive $seconds in UNIX timestamp, you can format that for a easier function :P
function onGetRequestLastSeen($username, $msgid, $seconds)
{
	//echo "Received last seen seconds: '$seconds'";
    //$now = time();
    //$lastSeen = $now - $seconds;
   
    $secondsInAMinute = 60;
    $secondsInAnHour  = 60 * $secondsInAMinute;
    $secondsInADay    = 24 * $secondsInAnHour;

    // extract days
    $days = floor($seconds / $secondsInADay);

    // extract hours
    $hourSeconds = $seconds % $secondsInADay;
    $hours = floor($hourSeconds / $secondsInAnHour);

    // extract minutes
    $minuteSeconds = $hourSeconds % $secondsInAnHour;
    $minutes = floor($minuteSeconds / $secondsInAMinute);

    // extract the remaining seconds
    $remainingSeconds = $minuteSeconds % $secondsInAMinute;
    $seconds = ceil($remainingSeconds);

    // return the value
    if (($seconds==null) & ($minutes==null) & ($hours==null) & ($days==null))
    	echo "El contacto tiene desactivado esta función";
    else if (($seconds==0) & ($minutes==0) & ($hours==0) & ($days==0))
    	echo "En línea";
    else
    	echo $days . " días " . $hours . " horas " . $minutes . " minutos";
  
}

$w->eventManager()->bind('onGetRequestLastSeen', 'onGetRequestLastSeen');
$w->sendGetRequestLastSeen($dst);

// See Event Manager in WhatsAPI-Spanish repo for more info.

Requesting profile picture / Obteniendo la imagen de perfil

function onGetProfilePicture($from, $target, $type, $data)
{
    if ($type == "preview") {
        $filename = "preview_" . $target . ".jpg";
    } else {
        $filename = $target . ".jpg";
    }
    $filename = WhatsProt::PICTURES_FOLDER."/" . $filename;
    
    $fp = @fopen($filename, "w");
    if ($fp) {
        fwrite($fp, $data);
        fclose($fp);
    
    }
    
    echo '<a href="'.$filename.'"><center><img src="'.$filename.'" height="250" width="250"></center></a><br><br>';
      
}
//Create the whatsapp object and setup a connection.
//Retrieve large profile picture. Output is in /src/php/pictures/ (you need to bind a function
//to the event onProfilePicture so the script knows what to do.
$w->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$w->sendGetProfilePicture($target, true);

En construcción :D

whatsapp-tools's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.