gpt4 book ai didi

php - 无法连接到谷歌云连接服务器

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:39:19 25 4
gpt4 key购买 nike

我正在尝试在我的服务器和 Google 云连接服务器 (CCS) 之间打开 XMPP 连接,但它不起作用。我使用 PHP 编程并使用 JAXL 库。这是我的代码:

<?php
include_once 'jaxl.php';

$client = new JAXL(array(
'jid'=>'<my_sender_ID>@gcm.googleapis.com',
'pass'=>'my_API_key',
'auth_type'=>'PLAIN',
'host' => 'gcm.googleapis.com',
'port' => '5235',
'force_tls' => true
));
$client->start();
echo "done";
?>

然后我得到这个错误:

unable to connect tcp://gcm.googleapis.com:5235 with error no: 110, error str: Connection timed out

我做错了什么?

最佳答案

您应该通过 ssl 而不是 http 或 tcp 连接到 gcm.googleapis.com。

我通过修改 jaxl.php 来解决这个问题:

public function get_socket_path() {
return ($this->cfg['port'] == 5223 ? "ssl" : "tcp")."://".$this->cfg['host'].":".$this->cfg['port'];
}

到:

public function get_socket_path() {
return ($this->cfg['port'] == 5223 || $this->cfg['ssl'] == true ? "ssl" : "tcp")."://".$this->cfg['host'].":".$this->cfg['port'];
}

之后你可以初始化客户端:

$client = new JAXL(array(
'jid' => '<your-API-key>@gcm.googleapis.com',
'pass' => '<your-API-key>',
'host' => 'gcm.googleapis.com',
'port' => 5235,
'force_tls' => true,
'auth_type' => 'PLAIN',
'strict' => FALSE,
'ssl' => TRUE
));

关于php - 无法连接到谷歌云连接服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17190038/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com