Skip to content

Instantly share code, notes, and snippets.

@meseven
Last active April 18, 2020 16:32
Show Gist options
  • Save meseven/261f78adbdbf8ac5f57cc765b4073913 to your computer and use it in GitHub Desktop.
Save meseven/261f78adbdbf8ac5f57cc765b4073913 to your computer and use it in GitHub Desktop.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.wapim.io/api/v1/whatsapp/message/text');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"phone_number\": \"RECIPIENT_NUMBER\", \"message\" : \"Hello Wapim\"}");
$headers = array();
$headers[] = 'Token: YOUR_WAPIM_TOKEN';
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment