wechaty/php-wechaty

Cannot run locally after the server is configured

HelplessMan opened this issue · 14 comments

After checking this question : #12, I followed the address given by for configuration. : https://wechaty.js.org/docs/puppet-services/diy/
The environment variables are as follows

WECHATY_TOKEN=11ca3fe1-ecd6-4909-99c8-13d5a920f502
WECHATY_DOCKER=1
WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER=false
WECHATY_PUPPET_SERVER_PORT=8788
WECHATY_LOG=verbose
WECHATY_PUPPET=wechaty-puppet-wechat

Check whether it is valid:

https://api.chatie.io/v0/hosties/11ca3fe1-ecd6-4909-99c8-13d5a920f502

Part of the log output by the server operation:

11:17:58 VERB PuppetWeChatEvent onScan({code: 408, url: https://login.weixin.qq.com/qrcode/QeqnjBGfYw==})
11:17:58 VERB MemoryCard <puppet> set(PUPPET_WECHAT, [object Object],[object Object],[object Object])
11:17:58 VERB MemoryCard <11ca3fe1-ecd6-4909-99c8-13d5a920f502> save() to StorageFile</wechaty/11ca3fe1-ecd6-4909-99c8-13d5a920f502.memory-card.json>
11:17:58 VERB StorageFile save() to /wechaty/11ca3fe1-ecd6-4909-99c8-13d5a920f502.memory-card.json
11:17:58 VERB PuppetWeChat start() throttleQueue.subscribe() new item: [object Object]
11:17:58 INFO IoClient [5] https://login.weixin.qq.com/l/QeqnjBGfYw==
Online QR Code Image: https://wechaty.js.org/qrcode/https%3A%2F%2Flogin.weixin.qq.com%2Fl%2FQeqnjBGfYw%3D%3D
11:17:58 VERB MemoryCard <puppet> set(PUPPET_WECHAT, [object Object],[object Object],[object Object])
11:17:58 VERB MemoryCard <11ca3fe1-ecd6-4909-99c8-13d5a920f502> save() to StorageFile</wechaty/11ca3fe1-ecd6-4909-99c8-13d5a920f502.memory-card.json>
11:17:58 VERB StorageFile save() to /wechaty/11ca3fe1-ecd6-4909-99c8-13d5a920f502.memory-card.json
11:19:58 WARN PuppetWeChat initScanWatchdog() on(reset) lastFood: [object Object], timePast: 120000
11:19:58 VERB PuppetWeChatBridge reload()
11:19:59 VERB PuppetWeChatBridge onLoad() page.url=https://wx.qq.com/?target=t
11:19:59 VERB PuppetWeChatBridge readyAngular()
11:19:59 VERB PuppetWeChatBridge inject()
11:19:59 VERB PuppetWeChatBridge ding(ding() OK!)
11:19:59 VERB PuppetWeChatBridge clickSwitchAccount()
11:20:00 VERB PuppetWeChatEvent onScan({code: 0, url: https://login.weixin.qq.com/qrcode/YYdEMQfQfw==})
11:20:00 VERB MemoryCard <puppet> set(PUPPET_WECHAT, [object Object],[object Object],[object Object])
11:20:00 VERB MemoryCard <11ca3fe1-ecd6-4909-99c8-13d5a920f502> save() to StorageFile</wechaty/11ca3fe1-ecd6-4909-99c8-13d5a920f502.memory-card.json>
11:20:00 VERB StorageFile save() to /wechaty/11ca3fe1-ecd6-4909-99c8-13d5a920f502.memory-card.json
11:20:00 INFO IoClient [2] https://login.weixin.qq.com/l/YYdEMQfQfw==
Online QR Code Image: https://wechaty.js.org/qrcode/https%3A%2F%2Flogin.weixin.qq.com%2Fl%2FYYdEMQfQfw%3D%3D
11:20:25 VERB PuppetWeChatEvent onScan({code: 408, url: https://login.weixin.qq.com/qrcode/YYdEMQfQfw==})
11:20:25 VERB MemoryCard <puppet> set(PUPPET_WECHAT, [object Object],[object Object],[object Object])
11:20:25 VERB MemoryCard <11ca3fe1-ecd6-4909-99c8-13d5a920f502> save() to StorageFile</wechaty/11ca3fe1-ecd6-4909-99c8-13d5a920f502.memory-card.json>
11:20:25 VERB StorageFile save() to /wechaty/11ca3fe1-ecd6-4909-99c8-13d5a920f502.memory-card.json
11:20:25 INFO IoClient [5] https://login.weixin.qq.com/l/YYdEMQfQfw==
Online QR Code Image: https://wechaty.js.org/qrcode/https%3A%2F%2Flogin.weixin.qq.com%2Fl%2FYYdEMQfQfw%3D%3D

After the configuration is complete, you can scan the code and see the chat information of the WeChat group under the cli. But in this case, how can I develop for some functions?

I also downloaded the php-wechaty package and configured it in the local env:

export WECHATY_TOKEN='11ca3fe1-ecd6-4909-99c8-13d5a920f502'
export WECHATY_PUPPET_HOSTIE_ENDPOINT=https://api.chatie.io/v0/hosties/11ca3fe1-ecd6-4909-99c8-13d5a920f502
export WECHATY_PUPPET_SERVICE_TOKEN=11ca3fe1-ecd6-4909-99c8-13d5a920f502
ps: `WECHATY_PUPPET_SERVICE_TOKEN` 参数我用了文档中的uuid 和 在 pad-local申请的 token 都尝试过。 不可以

local code:

<?php
/**
 * Created by PhpStorm.
 * User: peterzhang
 * Date: 2020/7/22
 * Time: 1:53 PM
 */

use IO\Github\Wechaty\Puppet\FileBox\FileBox;
use IO\Github\Wechaty\User\ContactSelf;
use IO\Github\Wechaty\User\MiniProgram;
use IO\Github\Wechaty\User\UrlLink;

define("ROOT", dirname(__DIR__));
// DEBUG should create dir use command sudo mkdir /var/log/wechaty && sudo chmod 777 /var/log/wechaty
define("DEBUG", 1);
require ROOT . '/vendor/autoload.php';

// change dir
// \IO\Github\Wechaty\Util\Logger::$_LOGGER_DIR = "/tmp/";

$token = getenv("WECHATY_PUPPET_SERVICE_TOKEN");
$endPoint = getenv("WECHATY_PUPPET_HOSTIE_ENDPOINT");
$wechaty = \IO\Github\Wechaty\Wechaty::getInstance($token, $endPoint);
$wechaty->onScan(function($qrcode, $status, $data) {
    if($status == 3) {
        echo "SCAN_STATUS_CONFIRMED\n";
    } else {
        $qr = \IO\Github\Wechaty\Util\QrcodeUtils::getQr($qrcode);
        echo "$qr\n\nOnline Image: https://wechaty.github.io/qrcode/$qrcode\n";
    }
})->onLogin(function(ContactSelf $user) {
    echo "login user id " . $user->getId() . "\n";
    echo "login user name " . $user->getPayload()->name . "\n";
})->onMessage(function(\IO\Github\Wechaty\User\Message $message) use ($wechaty) {
    $name = $message->from()->getPayload()->name;
    $text = $message->getPayload()->text;
    echo "message from user name $name : $text\n";
    if($text == "ding") {
        $message->say("dong");
    } else if($text == "_stop_") {
        $wechaty->stop();
    } else {
        $message->say("hello $name from php-wechaty");
    }
})->onHeartBeat(function($data) use ($wechaty) {
    echo $data . "\n";
})->start();

After executing the code, an error occurred:

http://81.70.210.141/wechaty.log

I am a little confused now.
There are some doubts about a few questions. According to the above document, what is the difference between uuid as a token and a token applied for in pad-local? Can it meet the needs that can be used to develop WeChat locally?

What is the role of the token applied for by pad-local? It is not clear that I took the wrong step.

In addition, I also checked this document and tried to use it
https://wechaty.js.org/docs/puppet-services/padlocal
But no results

English is not good, but to follow the rules. Use translator to convert to English. Maybe a bit blunt. . Say sorry....

Please check the result of https://api.chatie.io/v0/hosties/11ca3fe1-ecd6-4909-99c8-13d5a920f502. You must make sure the ip and port can be reached.

Your WECHATY_PUPPET_HOSTIE_ENDPOINT is wrong.

export WECHATY_PUPPET_HOSTIE_ENDPOINT=127.0.0.1:8878

When I was debugging, the service was available, and now it's down

When I guarantee that the service is available. Do you just specify
WECHATY_PUPPET_HOSTIE_ENDPOINT=service ip:port is enough?
Is it feasible if I call the services of the external network locally?

When I was debugging, the service was available, and now it's down

When I guarantee that the service is available. Do you just specify WECHATY_PUPPET_HOSTIE_ENDPOINT=service ip:port is enough? Is it feasible if I call the services of the external network locally?

You can use your ip instead of 127.0.01. If there is no WECHATY_PUPPET_HOSTIE_ENDPOINT, it will use the result of https://api.chatie.io/v0/hosties/11ca3fe1-ecd6-4909-99c8-13d5a920f502.

At the beginning I did not set the WECHATY_PUPPET_HOSTIE_ENDPOINT environment variable. Through the error message I saw that ENDPOINT got the https://api.chatie.io/v0/hosties/11ca3fe1-ecd6-4909-99c8-13d5a920f502 address . Because this service still cannot be started, I tried to set WECHATY_PUPPET_HOSTIE_ENDPOINT

But I still don't understand the difference between applying for a token on pad-local.com and using uuid4?

s the PUPPET method used differently? I found that no matter what it is, I need to build my own Puppet Service. When I see WECHATY_PUPPET login, it seems that it also prompts pad to log in

At the beginning I did not set the WECHATY_PUPPET_HOSTIE_ENDPOINT environment variable. Through the error message I saw that ENDPOINT got the https://api.chatie.io/v0/hosties/11ca3fe1-ecd6-4909-99c8-13d5a920f502 address . Because this service still cannot be started, I tried to set WECHATY_PUPPET_HOSTIE_ENDPOINT

But I still don't understand the difference between applying for a token on pad-local.com and using uuid4?

There are two tokens when run the bot service. The padlocal token is for the wechaty, not php-wechaty. If you run the bot service by Wechaty, You just need the padlocal token.

s the PUPPET method used differently? I found that no matter what it is, I need to build my own Puppet Service. When I see WECHATY_PUPPET login, it seems that it also prompts pad to log in

see https://wechaty.js.org/2021/02/03/python-wechaty-for-padlocal-puppet-service/

s the PUPPET method used differently? I found that no matter what it is, I need to build my own Puppet Service. When I see WECHATY_PUPPET login, it seems that it also prompts pad to log in

see https://wechaty.js.org/2021/02/03/python-wechaty-for-padlocal-puppet-service/

Follow the python-wechaty-for-padlocal-puppet-service given here I performed an operation, but the ENDPOINT address could not be found, and then tried to modify the WECHATY_PUPPET_HOSTIE_TOKEN to uuid4, and then the service stopped normally error occurred again

The picture below is the recorded GIF process that I operated. If you have time, please check it out. See where there is a problem

http://81.70.210.141/wechaty.gif

s the PUPPET method used differently? I found that no matter what it is, I need to build my own Puppet Service. When I see WECHATY_PUPPET login, it seems that it also prompts pad to log in

see https://wechaty.js.org/2021/02/03/python-wechaty-for-padlocal-puppet-service/

Follow the python-wechaty-for-padlocal-puppet-service given here I performed an operation, but the ENDPOINT address could not be found, and then tried to modify the WECHATY_PUPPET_HOSTIE_TOKEN to uuid4, and then the service stopped normally error occurred again

The picture below is the recorded GIF process that I operated. If you have time, please check it out. See where there is a problem

http://81.70.210.141/wechaty.gif

When starting export WECHATY_PUPPET_HOSTIE_TOKEN="puppet_padlocal_dae480b0f24e4a17be2a9xdfafdwfds" , after the error 404 appeared WECHATY_PUPPET_HOSTIE_ENDPOINT, I will modify it to IE8ePET6bexport WECHATY_PUPaPET_HOST-457c57
Will still appear

service stopped normally
{}

$token:af7b8196-01e0-4f57-a8fa-4c69bb0e6b0c
$endPoint:81.70.210.141:8788
root@aaa047ddc8c7:/var/www/php-wechaty-getting-started#

telnet 81.70.210.141 8788

export WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER="false"

export WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER="false"

I'm in a bad mood... Still can't

╰─$ telnet 81.70.210.141 8788

Trying 81.70.210.141...
Connected to 81.70.210.141.
Escape character is '^]'.

It looks good

service:
export WECHATY_LOG="verbose"
export WECHATY_PUPPET="wechaty-puppet-padlocal"
export WECHATY_PUPPET_PADLOCAL_TOKEN="puppet_padlocal_dae480b0f24e4a17be2a9e3443dcc44d"

export WECHATY_PUPPET_SERVER_PORT="8788"
export WECHATY_TOKEN="e2a2c07a-495f-4d32-9737-b577723cb003"

local:
export WECHATY_PUPPET="wechaty-puppet-service"
//export WECHATY_PUPPET_SERVICE_TOKEN="puppet_padlocal_dae480b0f24e4a17be2a9e3443dcc44d"
export WECHATY_PUPPET_SERVICE_TOKEN="e2a2c07a-495f-4d32-9737-b577723cb003"
export WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER="false"
export WECHATY_PUPPET_SERVICE_ENDPOINT="81.70.210.141:8788"

It's also good:

https://api.chatie.io/v0/hosties/e2a2c07a-495f-4d32-9737-b577723cb003

export WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER="false"

I'm in a bad mood... Still can't

╰─$ telnet 81.70.210.141 8788

Trying 81.70.210.141...
Connected to 81.70.210.141.
Escape character is '^]'.

It looks good

service:
export WECHATY_LOG="verbose"
export WECHATY_PUPPET="wechaty-puppet-padlocal"
export WECHATY_PUPPET_PADLOCAL_TOKEN="puppet_padlocal_dae480b0f24e4a17be2a9e3443dcc44d"

export WECHATY_PUPPET_SERVER_PORT="8788"
export WECHATY_TOKEN="e2a2c07a-495f-4d32-9737-b577723cb003"

local:
export WECHATY_PUPPET="wechaty-puppet-service"
//export WECHATY_PUPPET_SERVICE_TOKEN="puppet_padlocal_dae480b0f24e4a17be2a9e3443dcc44d"
export WECHATY_PUPPET_SERVICE_TOKEN="e2a2c07a-495f-4d32-9737-b577723cb003"
export WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER="false"
export WECHATY_PUPPET_SERVICE_ENDPOINT="81.70.210.141:8788"

It's also good:

https://api.chatie.io/v0/hosties/e2a2c07a-495f-4d32-9737-b577723cb003

service puppet:

Online QR Code Image: https://wechaty.js.org/qrcode/
05:33:56 VERB StateSwitch <PuppetState> off(pending) <- (false)
05:33:56 VERB StateSwitch <PuppetState> off(true) <- (pending)
05:33:57 VERB StateSwitch <PuppetState> on(pending) <- (false)
05:33:57 INFO [PuppetPadlocal] start login with type: QrLogin
05:33:58 INFO IoClient [2] http://weixin.qq.com/x/Adqo_Y0wgQi3krPvtpM5
Online QR Code Image: https://wechaty.js.org/qrcode/http%3A%2F%2Fweixin.qq.com%2Fx%2FAdqo_Y0wgQi3krPvtpM5
05:37:46 INFO IoClient [5]
Online QR Code Image: https://wechaty.js.org/qrcode/
05:37:46 VERB StateSwitch <PuppetState> off(pending) <- (false)
05:37:46 VERB StateSwitch <PuppetState> off(true) <- (pending)
05:37:48 VERB StateSwitch <PuppetState> on(pending) <- (false)
05:37:48 INFO [PuppetPadlocal] start login with type: QrLogin
05:37:48 INFO IoClient [2] http://weixin.qq.com/x/AeFNfuABicx8JvblVYLx
Online QR Code Image: https://wechaty.js.org/qrcode/http%3A%2F%2Fweixin.qq.com%2Fx%2FAeFNfuABicx8JvblVYLx
05:39:59 INFO Io on(jsonrpc): [object Object]
05:39:59 VERB Io on(jsonrpc) send({"id":-9007199254733465,"jsonrpc":"2.0","result":8788})
05:40:50 INFO Io on(jsonrpc): [object Object]
05:40:50 VERB Io on(jsonrpc) send({"id":-9007199254733457,"jsonrpc":"2.0","result":8788})