Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,46 @@ Among people who were involved: legal firms and counselors, sending all sorts of

So besides having no time or interest for the core project anymore, and not benefiting at all, not from this or from the work derived from it, comes more aggressive letters citing lengthy Computer Fraud and Abuse Act (CFAA) clauses and requiring compensation among other ridiculous demands and/or threats.

*I'm wiping this repository away.*
*I'm wiping this repository away.*

## Instructions for Obtaining a WhatsApp Password Using the API

### Phase 1: Request Code

```php
$username = "phone number with international prefix but without + and 00";
$identity = strtolower(urlencode(sha1($username, true)));
$w = new WhatsProt($username, $identity, "Your Name", true);
$w->codeRequest();
```

### Phase 2: Retrieve Password

```php
$username = "phone number with international prefix but without + and 00";
$identity = strtolower(urlencode(sha1($username, true)));
$w = new WhatsProt($username, $identity, "Your Name", true);
$result = $w->codeRegister("your 6 digit SMS code");
$password = $result->pw;
echo "Password is $password";
```

### Phase 3: Send Message

```php
$username = "phone number with international prefix but without + and 00";
$identity = strtolower(urlencode(sha1($username, true)));
$w = new WhatsProt($username, $identity, "Your Name", true);
$password = 'YourPassword';
$w->Connect();
$w->LoginWithPassword($password);

$dst = 'destination number with international prefix but without + and 00';
$msg = 'Your message text';
$w->sendMessage($dst, $msg);
$w->disconnect();
```

### Note

You need to enable the `php_curl` extension in your PHP configuration.
43 changes: 43 additions & 0 deletions exampleRegister.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
// exampleRegister.php

// Include the WhatsProt class
require_once 'whatsprot.class.php';

// Define your phone number with international prefix but without + and 00
$username = "phone number with international prefix but without + and 00";

// Generate the identity
$identity = strtolower(urlencode(sha1($username, true)));

// Create a new instance of WhatsProt
$w = new WhatsProt($username, $identity, "Your Name", true);

// Request a code
$w->codeRequest();

// Register the code
$result = $w->codeRegister("your 6 digit SMS code");

// Retrieve the password
$password = $result->pw;
echo "Password is $password";

// Connect to WhatsApp
$w->Connect();

// Login with the password
$w->LoginWithPassword($password);

// Define the destination number with international prefix but without + and 00
$dst = 'destination number with international prefix but without + and 00';

// Define the message text
$msg = 'Your message text';

// Send the message
$w->sendMessage($dst, $msg);

// Disconnect from WhatsApp
$w->disconnect();
?>
91 changes: 91 additions & 0 deletions whatsprot.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

class WhatsProt
{
// Class properties and methods

public function codeRequest($method = "sms", $countryCode = null, $languageCode = null)
{
// Generate the request parameters
$params = array(
"cc" => $this->countryCode,
"in" => $this->phoneNumber,
"to" => $this->phoneNumber,
"lg" => $languageCode ? $languageCode : $this->languageCode,
"lc" => $countryCode ? $countryCode : $this->countryCode,
"method" => $method,
"mcc" => $this->mcc,
"mnc" => $this->mnc,
"token" => $this->generateToken(),
"id" => $this->identity
);

// Send the request
$response = $this->sendRequest("code", $params);

// Handle the response
return $this->handleResponse($response);
}

public function codeRegister($code)
{
// Generate the request parameters
$params = array(
"cc" => $this->countryCode,
"in" => $this->phoneNumber,
"to" => $this->phoneNumber,
"lg" => $this->languageCode,
"lc" => $this->countryCode,
"code" => $code,
"id" => $this->identity
);

// Send the request
$response = $this->sendRequest("register", $params);

// Handle the response
return $this->handleResponse($response);
}

private function sendRequest($endpoint, $params)
{
// Initialize cURL
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $this->apiUrl . $endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the request
$response = curl_exec($ch);

// Close cURL
curl_close($ch);

// Return the response
return $response;
}

private function handleResponse($response)
{
// Decode the response
$result = json_decode($response);

// Check for errors
if (isset($result->status) && $result->status == "fail") {
throw new Exception("Error: " . $result->reason);
}

// Return the result
return $result;
}

private function generateToken()
{
// Generate a token based on the phone number and identity
return md5($this->phoneNumber . $this->identity);
}
}
?>