簡體   English   中英

使用php發送whatsapp消息

[英]send whatsapp message using php

你好。 我想使用 php 發送 whatsapp 消息。 我運行這段代碼

 <?php require_once 'Chat-API-master/src/whatsprot.class.php'; $username = "6285648145xxx"; $nickname = "ardi"; $password = "password"; // The one we got registering the number $debug = true; // Create a instance of WhastPort. $w = new WhatsProt($username, $nickname, $debug); $w->connect(); // Connect to WhatsApp network $w->loginWithPassword($password); // logging in with the password we got! $target = '62811304xxxx'; // The number of the person you are sending the message $message = 'Hi! :) this is a test message'; $w->sendMessage($target , $message); ?>

但我在我的瀏覽器中得到了這段代碼

 tx <stream:features></stream:features> tx <auth user="6285648145xxx" mechanism="WAUTH-2"></auth> rx <from s.whatsapp.net=""></from> rx <stream:features></stream:features> rx <challenge>376a507c7e915642d85255fe96cb1d101fa23819</challenge> tx <response>200e09fa50b7c6a3fa3416878f1e165e8d7670f054ddeaa1c77278a5f8e5b881f4f9f75dce809f42cbdcf17931db8c15641399488b90e9cb74e87de94560802f98bb028af9b5967403fb278c28e06c</response> Fatal error: Maximum execution time of 30 seconds exceeded in D:\XAMPP\htdocs\waonline\Chat-API-master\src\whatsprot.class.php on line 2609

怎么了?? 請給我解決方案。 謝謝

添加

set_time_limit(120);

您的腳本執行時間過長

使用官方的“點擊聊天”API

第一種可能的方法是通過 URL 過程將用戶發送到:

https://api.whatsapp.com/send?phone=XXYYYYYYYY

(其中XX是國家代碼, YYYYYYYY是數字)

如今,API 以更短的格式出現,並允許包含文本消息。

https://wa.me/whatsappphonenumber/?text=urlencodedtext

(其中whatsappphonenumber是國際格式的完整電話號碼, URL-encodedtext是 URL 編碼的預填充消息)

也可以只指定要發送的消息,但沒有指定用戶,讓用戶稍后選擇將其發送給誰,可以一次將其發送給許多人,使用以下方法:

https://wa.me/?text=urlencodedtext

您可以在這里查看所有官方當前信息https://faq.whatsapp.com/en/android/26000030/

官方文檔說要使用他們的 wa.me URL ,所以讓我們看看: http ://wa.me/?text=mytest。 你看到了什么? 您是否看到錯誤頁面? 這就是我所看到的:

我們找不到您要查找的頁面

看起來您正在尋找一個不存在的頁面。 或者我們可能剛剛刪除的頁面。 無論哪種方式,請返回或確保檢查 url、您的拼寫並重試。

所以,簡而言之,不要使用 wa.me URL 使用api.whatsapp.com URL,例如以下之一:

https://api.whatsapp.com/send?text=YourShareTextHere

https://api.whatsapp.com/send?text=YourShareTextHere&phone=123

這兩個都適合我!

如果您有興趣觀看跟蹤這些 URL 的項目,請查看我們!: https ://github.com/bradvin/social-share-urls#whatsapp

社交分享網址

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM