• 0
Likes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/post.php

Line Number: 190

Backtrace:

File: /home2/naijacod/public_html/application/views/post.php
Line: 190
Function: _error_handler

File: /home2/naijacod/public_html/application/controllers/Posts.php
Line: 420
Function: view

File: /home2/naijacod/public_html/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

How to send a PDF file to a WhatsApp user in PHP

This article shows you how to send a document (e.g. a PDF file, an MP4 file, a WAV file, etc.) to a registered WhatsApp user in PHP.

Before the recipient can receive your WhatsApp message, she MUST register with the WhatsMate WA Gateway. Instructions are available on the official siteUnregistered users will never receive messages from the Gateway.

To send a WhatsApp message containing a PDF document in PHP, do this:

  1. First, learn how to send a simple text message on the official site.
  2. With the above knowledge, you can now download our sample code.
  3. Locate the file php/send-pdf-individual.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 Premium client ID here
      $CLIENT_SECRET = "YOUR_CLIENT_SECRET_HERE"; // TODO: Replace it with your Premium client secret here
       
      $pathToDocument = "/tmp/your_doc.pdf"; // TODO: Replace it with the path to your document
      $docData = file_get_contents($pathToDocument);
      $base64Doc = base64_encode($docData);
      $fn = "anyname.pdf"; // TODO: Replace it with a name you like
       
      $postData = array(
      'number' => '12025550108', // TODO: Specify the recipient's number (NOT the gateway number) here.
      'document' => $base64Doc,
      'filename' => $fn
      );
       
      $headers = array(
      'Content-Type: application/json',
      'X-WM-CLIENT-ID: '.$CLIENT_ID,
      'X-WM-CLIENT-SECRET: '.$CLIENT_SECRET
      );
       
      $url = 'http://api.whatsmate.net/v3/whatsapp/single/document/message/' . $INSTANCE_ID;
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
      $response = curl_exec($ch);
      echo "Response: ".$response;
      curl_close($ch);
      ?>

     

  4. Study the PHP source code and customize the TODO/FIXME lines.

    • Among other things, put down YOUR OWN number as the recipient. You can’t send messages to strangers because we are against SPAMMERS.
  5. Visit the PHP page you just created to send your image.

Happy coding :)

 

 

Source

Added a comment on Jun 25,2020

*FREE BEGINNERS MASTERCLASS IN FOREX TRADING*

Are you a forex beginner who finds forex frustrating and difficult to learn, or you want to start trading but you don't know how?

You don't have to worry, this beginners masterclass is for you to gain knowledge from the bases and equip yourself to be a better trader.

*In this masterclass you will have the chance to learn*

1)What forex trading is.
2)Terminologies and their meanings 
3)Candlesticks- tools used in reading the price chart
4(Drawing support and resistance.
5)Reasons why trading the forex market can be beneficial to you
6)Mentoring AND MORE 

The amazing thing is that all the bullet points above will be taught for FREE in this masterclass.

So much to learn, NO FEE to pay, so why waste the time

Join the largest capital market in the world. 

*Click the link below to join the class*

  • 0
Reply Report