aldinokemal / go-whatsapp-web-multidevice

API for Whatsapp Web Multi Device Version, Support UI & Webhook
MIT License
582 stars 245 forks source link

Send messages via PHP #65

Closed tmgallage closed 1 year ago

tmgallage commented 1 year ago

Hello,

I have already running at 3000 port in my server. I want to send messages via PHP. But I can't find a way. I hope it can do by POST method or something.

Thank You.

aldinokemal commented 1 year ago

you can use Guzzle Http

<?php
$client = new Client();
$headers = [
  'Authorization' => 'Basic a2VtYWw6MjEwNA=='
];
$options = [
  'multipart' => [
    [
      'name' => 'phone',
      'contents' => '6283866237125-1365595428'
    ],
    [
      'name' => 'file',
      'contents' => Utils::tryFopen('/Users/aldinokemal/Pictures/bbkkp.png', 'r'),
      'filename' => '/Users/aldinokemal/Pictures/bbkkp.png',
      'headers'  => [
        'Content-Type' => '<Content-type header>'
      ]
    ],
    [
      'name' => 'caption',
      'contents' => ''
    ]
]];
$request = new Request('POST', '{{HOSTNAME}}/send/file', $headers);
$res = $client->sendAsync($request, $options)->wait();
echo $res->getBody();
tmgallage commented 1 year ago

Thank you very much, i will try this now