Skip to content

Instantly share code, notes, and snippets.

@whatsmate
whatsmate / send-whatsapp.sh
Last active June 7, 2020 16:12
Sending a WhatsApp Message from a shell script
#!/bin/bash
INSTANCE_ID="YOUR_INSTANCE_ID_HERE" # TODO: Replace it with your gateway instance ID here
CLIENT_ID="YOUR_CLIENT_ID_HERE" # TODO: Replace it with your "Forever Green" client ID here
CLIENT_SECRET="YOUR_CLIENT_SECRET_HERE" # TODO: Replace it with your "Forever Green" client secret here
# TODO: Specify the recipient's number (NOT the gateway number) on line 10.
read -r -d '' jsonPayload << _EOM_
{
"number": "12025550108",
@whatsmate
whatsmate / send-whatsapp.js
Last active May 1, 2024 12:38
Sending a WhatsApp message in Node.js
#!/usr/bin/env node
var http = require('http');
var instanceId = "YOUR_INSTANCE_ID_HERE"; // TODO: Replace it with your gateway instance ID here
var clientId = "YOUR_CLIENT_ID_HERE"; // TODO: Replace it with your Forever Green client ID here
var clientSecret = "YOUR_CLIENT_SECRET_HERE"; // TODO: Replace it with your Forever Green client secret here
var jsonPayload = JSON.stringify({
number: "12025550108", // TODO: Specify the recipient's number here. NOT the gateway number
@whatsmate
whatsmate / WhatsappSender.java
Last active April 24, 2023 07:49
Sending a WhatsApp message in Java
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class WhatsappSender {
// TODO: Replace the following with your instance ID, Forever Green Client ID and Secret:
private static final String INSTANCE_ID = "YOUR_INSTANCE_ID_HERE";
private static final String CLIENT_ID = "YOUR_CLIENT_ID_HERE";
@whatsmate
whatsmate / send-whatsapp.ps1
Last active April 9, 2020 22:44
Sending a WhatsApp message from a Powershell script
$number = "12025550108" # Specify the recipient's number here. NOT the gateway number
$message = "Howdy, this is a message from PowerShell."
$instanceId = "YOUR_INSTANCE_ID_HERE" # TODO: Replace it with your gateway instance ID
$clientId = "YOUR_CLIENT_ID_HERE" # TODO: Replace it with your Forever Green client ID here
$clientSecret = "YOUR_CLIENT_SECRET_HERE" # TODO: Replace it with your Forever Green client secret here
$jsonObj = @{'number'=$number;
'message'=$message;}
@whatsmate
whatsmate / send-whatsapp.php
Last active July 16, 2021 18:49
Sending a WhatsApp message from php
<?php
$INSTANCE_ID = 'YOUR_INSTANCE_ID_HERE'; // TODO: Replace it with your gateway instance ID here
$CLIENT_ID = "YOUR_CLIENT_ID_HERE"; // TODO: Replace it with your Forever Green client ID here
$CLIENT_SECRET = "YOUR_CLIENT_SECRET_HERE"; // TODO: Replace it with your Forever Green client secret here
$postData = array(
'number' => '12025550108', // TODO: Specify the recipient's number here. NOT the gateway number
'message' => 'Howdy! Is this exciting?'
);
@whatsmate
whatsmate / send-whatsapp.cs
Last active May 30, 2024 11:57
Sending a WhatsApp message in C#
using System;
using System.Net;
using System.Web.Script.Serialization; // requires the reference 'System.Web.Extensions'
using System.IO;
using System.Text;
class WaMessageSender
{
// TODO: Replace the following with your gateway instance ID, Forever Green client ID and secret:
private static string INSTANCE_ID = "YOUR_INSTANCE_ID_HERE";
@whatsmate
whatsmate / send-whatsapp.vb
Last active December 3, 2020 11:57
Sending a WhatsApp message in VB.NET
Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Web.Script.Serialization
Public Class WaMessageSender
''' TODO: Replace the following with your gateway instance ID, Forever Green client ID and secret below:
Private Const INSTANCE_ID As String = "YOUR_INSTANCE_ID_HERE"
@whatsmate
whatsmate / send-whatsapp.gs
Last active July 16, 2023 11:05
Sending a WhatsApp message from Google Apps Script
function main() {
var destNumber = "12025550108"; // TODO: Specify the recipient's number here. NOT THE GATEWAY NUMBER!
var message = "Aloha, this is my first message.";
sendWhatsapp(destNumber, message);
}
function sendWhatsapp(destNumber, message) {
var instanceId = "YOUR_INSTANCE_ID_HERE"; // TODO: Replace it with your gateway instance ID here
var clientId = "YOUR_CLIENT_ID_HERE"; // TODO: Replace it with your Forever Green client ID here
@whatsmate
whatsmate / translate-text.sh
Last active August 23, 2016 02:28
Translating Text from a shell script
#!/bin/bash
# TODO: If you have your own Client ID and secret, put down their values here:
CLIENT_ID="FREE_TRIAL_ACCOUNT"
CLIENT_SECRET="PUBLIC_SECRET"
# TODO: Specify your translation requirements here:
fromLang="en"
toLang="id"
text="Let's have some fun!"
@whatsmate
whatsmate / translate-text.py
Last active October 17, 2016 03:36
Translating text in Python
#!/usr/bin/env python
import requests
# TODO: If you have your own Client ID and secret, put down their values here:
clientId = "FREE_TRIAL_ACCOUNT"
clientSecret = "PUBLIC_SECRET"
# TODO: Specify your translation requirements here:
fromLang = "en"