All Projects → wechaty → php-wechaty

wechaty / php-wechaty

Licence: Apache-2.0 License
PHP Wechaty is a Conversational SDK for Chatbot Makers Written in PHP

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to php-wechaty

java-wechaty-getting-started
Java Wechaty Starter Project Template that Works Out-of-the-Box
Stars: ✭ 30 (-14.29%)
Mutual labels:  chatbot, wechaty
Wechaty
Conversational RPA SDK for Chatbot Makers
Stars: ✭ 11,647 (+33177.14%)
Mutual labels:  chatbot, wechaty
osschat
Apache Open Source Software Chat BOT
Stars: ✭ 115 (+228.57%)
Mutual labels:  chatbot, wechaty
php-rdkafka-ffi
PHP Kafka client - binding librdkafka via FFI
Stars: ✭ 49 (+40%)
Mutual labels:  php74
chatbase-dotnet
Integrate your DotNet application with Chatbase!
Stars: ✭ 16 (-54.29%)
Mutual labels:  chatbot
lita-hipchat
A HipChat adapter for Lita.
Stars: ✭ 37 (+5.71%)
Mutual labels:  chatbot
botyo
Modular chatbot framework designed for group chat rooms on Facebook
Stars: ✭ 17 (-51.43%)
Mutual labels:  chatbot
magento2-fast-vm
Optimal vagrant developer box for Magento2. Folders synced by nfs/rsync. This box includes Magento developer utilities.
Stars: ✭ 89 (+154.29%)
Mutual labels:  php74
CHIT-CHAT
A Covid-19 Chatbot that aims to serve humans queries and give a feasible answer to their queries.
Stars: ✭ 18 (-48.57%)
Mutual labels:  chatbot
intelligo-generator
🛠️ Chatbot generator for Intelligo Framework.
Stars: ✭ 31 (-11.43%)
Mutual labels:  chatbot
typed
Typed variables for PHP 7.4+ ( don't use this please )
Stars: ✭ 66 (+88.57%)
Mutual labels:  php74
sepia-docs
Documentation and Wiki for SEPIA. Please post your questions and bug-reports here in the issues section! Thank you :-)
Stars: ✭ 160 (+357.14%)
Mutual labels:  chatbot
OwOFrame
A lightweight MVC framework for PHP
Stars: ✭ 46 (+31.43%)
Mutual labels:  php74
Daytripper
Chatbot that learns and provides map, video, and Web searches.
Stars: ✭ 14 (-60%)
Mutual labels:  chatbot
memorize-bot
Memorize messenger bot using intelligo framework.
Stars: ✭ 19 (-45.71%)
Mutual labels:  chatbot
neo4j protobot
a basic bot to evaluate using neo4j graph database as chatbot memory.
Stars: ✭ 15 (-57.14%)
Mutual labels:  chatbot
docker-hubot
Docker container for running hubot in a container.
Stars: ✭ 17 (-51.43%)
Mutual labels:  chatbot
SpaceFusion
NAACL'19: "Jointly Optimizing Diversity and Relevance in Neural Response Generation"
Stars: ✭ 73 (+108.57%)
Mutual labels:  chatbot
mafia host bot
Bot that hosts mafia games in Telegram's groups and supergroups
Stars: ✭ 16 (-54.29%)
Mutual labels:  chatbot
facebook-send-api-emulator
Facebook Messenger Emulator & Facebook Send API Emulator functionality allowing you to test web hooks on developer's machine.
Stars: ✭ 24 (-31.43%)
Mutual labels:  chatbot

php-wechaty

Packagist PHP Version Support PHP

PHP Wechaty

PHP Wechaty Getting Started Wechaty in PHP

Connecting Chatbots

Powered by Wechaty

Wechaty is a Conversational SDK for Chatbot Makers that can help you create a bot in 8 lines of PHP

Voice of the Developers

"Wechaty is a great solution, I believe there would be much more users recognize it." link
— @Gcaufy, Tencent Engineer, Author of WePY

"太好用,好用的想哭"
— @xinbenlv, Google Engineer, Founder of HaoShiYou.org

"最好的微信开发库" link
— @Jarvis, Baidu Engineer

"Wechaty让运营人员更多的时间思考如何进行活动策划、留存用户,商业变现" link
— @lijiarui, Founder & CEO of Juzi.BOT.

"If you know js ... try Wechaty, it's easy to use."
— @Urinx Uri Lee, Author of WeixinBot(Python)

See more at Wiki:Voice Of Developer

Join Us

Wechaty is used in many ChatBot projects by thousands of developers. If you want to talk with other developers, just scan the following QR Code in WeChat with secret code php wechaty, join our Wechaty PHP Developers' Home.

Wechaty Friday.BOT QR Code

Scan now, because other Wechaty PHP developers want to talk with you too! (secret code: php wechaty)

Getting Started

1. Docker

Docker Pulls Docker Layers

PHP Wechaty Docker supports PHP Script.

2.1. Run php script

# for php script
docker run -ti --volume="$(pwd)":/bot --rm phpwechaty/php-wechaty:v1 docker/ding-dong-bot.php

Learn more about Wechaty Docker at Wiki:Docker.

New environment variables

  1. WECHATY_PUPPET_SERVICE_TLS_CA_CERT: can be overwrite by options.tlsRootCert. Set Root CA Cert to verify the server or client.

For Puppet Server:

Environment Variable Options Description
WECHATY_PUPPET_SERVICE_TLS_SERVER_CERT options.tls.serverCert Server CA Cert (string data)
WECHATY_PUPPET_SERVICE_TLS_SERVER_KEY options.tls.serverKey Server CA Key (string data)
WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER options.tls.disable Set true to disable server TLS

For Puppet Client:

Environment Variable Options Description
WECHATY_PUPPET_SERVICE_AUTHORITY options.authority Service discovery host, default: api.chatie.io
WECHATY_PUPPET_SERVICE_TLS_CA_CERT options.caCert Certification Authority Root Cert, default is using Wechaty Community root cert
WECHATY_PUPPET_SERVICE_TLS_SERVER_NAME options.serverName Server Name (mast match for SNI)
WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT options.tls.disable Set true to disable client TLS

Learn more about tls at https://github.com/wechaty/puppet-service

The World's Shortest PHP ChatBot: 8 lines of Code

php

$wechaty = \IO\Github\Wechaty\Wechaty::getInstance($token, $endPoint);
$wechaty->onScan(function($qrcode, $status, $data) {
    $qr = \IO\Github\Wechaty\Util\QrcodeUtils::getQr($qrcode);
    echo "$qr\n\nOnline Image: https://wechaty.github.io/qrcode/$qrcode\n";
})->onLogin(function(\IO\Github\Wechaty\User\ContactSelf $user) {
})->onMessage(function(\IO\Github\Wechaty\User\Message $message) {
    $message->say("hello from PHP7.4");
})->start();

PHP Wechaty Developing Plan

We already have Wechaty in TypeScript, It will be not too hard to translate the TypeScript(TS) to PHP because wechaty has only 3,000 lines of the TS code, they are well designed and de-coupled by the wechaty-puppet abstraction. So after we have translated those 3,000 lines of TypeScript code, we will almost be done.

As we have already a ecosystem of Wechaty in TypeScript, so we will not have to implement everything in PHP, especially, in the Feb 2020, we have finished the @chatie/grpc service abstracting module with the wechaty-puppet-service implmentation.

The following diagram shows out that we can reuse almost everything in TypeScript, and what we need to do is only the block located at the top right of the diagram: Wechaty (PHP).

  +--------------------------+ +--------------------------+
  |                          | |                          |
  |   Wechaty (TypeScript)   | |      Wechaty (PHP)        |
  |                          | |                          |
  +--------------------------+ +--------------------------+

  +-------------------------------------------------------+
  |                 Wechaty Puppet Service                 |
  |                                                       |
  |                (wechaty-puppet-service)                |
  +-------------------------------------------------------+

+---------------------  @chatie/grpc  ----------------------+

  +-------------------------------------------------------+
  |                Wechaty Puppet Abstract                |
  |                                                       |
  |                   (wechaty-puppet)                    |
  +-------------------------------------------------------+

  +--------------------------+ +--------------------------+
  |      Pad Protocol        | |      Web Protocol        |
  |                          | |                          |
  | wechaty-puppet-padplus   | |(wechaty-puppet-puppeteer)|
  +--------------------------+ +--------------------------+
  +--------------------------+ +--------------------------+
  |    Windows Protocol      | |       Mac Protocol       |
  |                          | |                          |
  | (wechaty-puppet-windows) | | (wechaty-puppet-macpro)  |
  +--------------------------+ +--------------------------+

Example: How to Translate TypeScript to PHP

There's a 100 lines class named Image in charge of downloading the WeChat image to different sizes.

It is a great example for demonstrating how do we translate the TypeScript to PHP in Wechaty Way:

Image Class Source Code

If you are interested in the translation and want to look at how it works, it will be a good start from reading and comparing those two Image class files in TypeScript and PHP at the same time.

To-do List

  • TS: TypeScript
  • SLOC: Source Lines Of Code

Wechaty Internal Modules

  1. Class Wechaty
  2. Class Contact
  3. Class ContactSelf
  4. Class Message
  5. Class Room
  6. Class Image
  7. Class Accessory
  8. Class Config
  9. Class Favorite
  10. Class Friendship
  11. Class MiniProgram
  12. Class RoomInvitation
  13. Class Tag
  14. Class UrlLink

Wechaty External Modules

  1. Class FileBox
  2. Class MemoryCard
  3. Class WechatyPuppet
  4. Class WechatyPuppetService

Usage

WIP...

docker

docker build -t php-wechaty:v1 .
docker run -ti --volume="$(pwd)":/bot --rm php-wechaty:v1 docker/ding-dong-bot.php

Requirements

  1. PHP 7.4+

Install

pecl安装

pecl install grpc
pecl install protobuf
pecl install yac

CentOS yum安装

# php make sure is 7.4+
sudo yum install php-pecl-grpc
sudo yum install php-pecl-protobuf
sudo yum install php-pecl-yac
sudo yum install php-xml

# php74
sudo yum install php74-php-pecl-grpc
sudo yum install php74-php-pecl-protobuf
sudo yum install php74-php-pecl-yac
sudo yum install php74-php-xml

# php[x]
sudo yum install php[x]-php-pecl-grpc
sudo yum install php[x]-php-pecl-protobuf
sudo yum install php[x]-php-pecl-yac
sudo yum install php[x]-php-xml

Yac enable

yac.enable=1
yac.enable_cli=1

composer

composer config repo.packagist composer https://mirrors.aliyun.com/composer/
# https://packagist.org/packages/wechaty/php-wechaty
composer require wechaty/php-wechaty

test

php examples/bot.php

Development

See Also

PHP for Node.js Developer

History

master

v0.0.1 (Jul 09, 2020)

  1. Project created.
  2. Welcome our first PHP Wechaty contributor:

Related Projects

  • Wechaty - Conversatioanl AI Chatot SDK for Wechaty Individual Accounts (TypeScript)
  • Python Wechaty - Python WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Python)
  • Go Wechaty - Go WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Go)
  • Java Wechaty - Java WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Java)
  • Scala Wechaty - Scala WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (Scala)
  • PHP Wechaty - PHP WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (PHP)
  • .NET(C#) Wechaty - .NET(C#) WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (.NET/C#)

Badge

Wechaty in PHP

[![Wechaty in PHP](https://img.shields.io/badge/Wechaty-PHP-7de)](https://github.com/wechaty/php-wechaty)

Contributors

  1. @zhangchunsheng - Chunsheng Zhang (张春生)

Creator

Copyright & License

  • Code & Docs © 2020 Wechaty Contributors https://github.com/wechaty
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].