wappico / wappi-php-client
为wappi.co提供的PHP SDK客户端
0.2.2
2024-04-24 23:46 UTC
Requires
- php: ^8.2
- illuminate/http: ~11
README
安装
composer require wappico/wappi-php-client
您只有在以下情况下才能联系WhatsApp上的人:(a) 他们已经给了您他们的手机号码;(b) 您已从收件人那里收到确认,他们希望您在WhatsApp上继续向您发送消息
- 同意加入必须(a) 明确说明该人正在选择通过WhatsApp接收您的消息,并且(b) 明确说明您的企业名称。
- 您独自负责确定同意加入的方式,确保您以符合您通信适用的法律的方式获得了同意加入,并且您已按照适用的法律提供了必要的通知和获得了必要的许可。
- 为了确保良好的用户体验,请查看以下建议的最佳实践。 https://business.whatsapp.com/policy#best_practices_for_optin
$whatsapp = new \Wappi\Client\Strategies\Whatsapp(apiKey: '') $whatsapp->phoneNumber("521782003377")->markAsOptIn();
向一个手机号码发送消息
$whatsapp = new \Wappi\Client\Strategies\Whatsapp(apiKey: '') $whatsapp->phoneNumber("521782003377"); $whatsapp->request([ \Wappi\Client\Message\Message::create(["text" => "¡Hi there!"]), \Wappi\Client\Message\Image::create(["url" => "https://wappi.co/image.png", "text" => "¡Hi there!"]), ]);
交互式列表
$whatsapp = new \Wappi\Client\Strategies\Whatsapp(apiKey: '',); $optionA = \Wappi\Client\Message\InteractiveListSectionOption::create([ "id" => "optionA", "title" => "title a", "description" => "description a", ]); $optionB = \Wappi\Client\Message\InteractiveListSectionOption::create([ "id" => 123, "title" => "title b", "description" => "description b", ]); $optionC = \Wappi\Client\Message\InteractiveListSectionOption::create([ "id" => "optionA123", "title" => "title c", "description" => "description c", ]); $sections = [ \Wappi\Client\Message\InteractiveListSection::create([ "title" => "First section", "description" => "some a", "options" => [ $optionA, ] ]), \Wappi\Client\Message\InteractiveListSection::create([ "title" => "Second section", "description" => "some b", "options" => [ $optionB, $optionC, ] ]) ]; \Wappi\Client\Message\InteractiveList::create([ "id" => 1111, "title" => "demo", "text" => "some description", "buttonTitle" => "Menú", "sections" => $sections ]);
交互式选项
$whatsapp = \Wappi\Client\Message\InteractiveText::create([ "id" => "", "header" => "", "text" => "", "footer" => "", "options" => [ \Wappi\Client\Message\InteractiveButton::create([ "id" => "foo", "text" => "bar" ]), \Wappi\Client\Message\InteractiveButton::create([ "id" => "foo2", "text" => "bar2" ]), \Wappi\Client\Message\InteractiveButton::create([ "id" => "foo3", "text" => "bar3" ]), ], ]);
联系方式
$whatsapp = \Wappi\Client\Message\Contact::create([ "name" => \Wappi\Client\Message\ContactName::create([ "firstName" => "Dev", "lastName" => "Support", "formattedName" => "Dev Support", ]), "org" => [ \Wappi\Client\Message\ContactOrg::create([ "company" => "Meta Inc.", ]) ], "emails" => [ \Wappi\Client\Message\ContactEmail::create([ "email" => "example@gmail.com", "type" => "WORK", ]) ], "phones" => [ \Wappi\Client\Message\ContactPhone::create([ "phone" => "7738305433", "type" => "Mobile", ]) ], "addresses" => [ \Wappi\Client\Message\ContactAddress::create([ "city" => "Menlo Park", "country" => "United States", "countryCode" => "us", "state" => "CA", "street" => "1 Hacker Way", "type" => "HOME", "zip" => "94025", ]), \Wappi\Client\Message\ContactAddress::create([ "city" => "Menlo Park", "country" => "United States", "countryCode" => "us", "state" => "CA", "street" => "200 Jefferson Dr", "type" => "WORK", "zip" => "94025", ]) ], "urls" => [ \Wappi\Client\Message\ContactAddress::create([ "url" => "https://#", "type" => "WORK", ]) ], ]);