连接到getstream php时出错

连接到getstream php时出错,php,curl,getstream-io,Php,Curl,Getstream Io,为了理解getstream io是如何工作的,我正在学习上的示例。我遇到了一个让我困惑的错误 require_once './vendor/autoload.php'; $client = new GetStream\Stream\Client('YOUR_API_KEY', 'API_KEY_SECRET'); $chris = $client->feed('user', 'chris'); // I replaced Your api key and api key se

为了理解getstream io是如何工作的,我正在学习上的示例。我遇到了一个让我困惑的错误

 require_once './vendor/autoload.php';
 $client = new GetStream\Stream\Client('YOUR_API_KEY',     'API_KEY_SECRET');
$chris = $client->feed('user', 'chris');
 // I replaced Your api key and api key secret with the one         in my dashboard
// Add an activity; message is a custom field - tip: add unlimited         custom fields!
$data = array(
"actor" => "chris",
"verb" => "add",
"object" => "picture:10",
"foreign_id" => "picture:10",
"message" => "Beautiful bird. Absolutely beautiful. Phenomenal bird."
);

$chris->addActivity($data);


// jack's 'timeline' feed follows chris' 'user' feed:
$jack = $client->feed('timeline', 'jack');
$jack->followFeed('user', 'chris');


// Read the 'timeline' feed for jack, chris' post will now show up: 
$activities = $jack->getActivities(10);
var_dump($activities);
在我的composer.json文件中,我这样做了

       "require": {
        "get-stream/stream": "2.2.8"
        }
我在windows上的本地主机上尝试了上述代码,但出现了此错误

Fatal error: Uncaught exception 'GuzzleHttp\ExceptionConnectException'     with message 'cURL error 28: Operation timed out after 0 milliseconds with 0 out of 0 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\xampp\htdocs\CorpersMate\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 186
 GuzzleHttp\Exception\ConnectException: cURL error 28: Operation timed out after 0 milliseconds with 0 out of 0 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in C:\xampp\htdocs\CorpersMate\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 186

伙计们,有什么想法吗?

你们应该提供指南-我们必须先注册才能拿到,这是不可能的

将第二行更改为

$client = new GetStream\Stream\Client(KEY, SECRET);

我将深入探讨为什么这对Xampp不起作用。你能给我们你的卷曲选项,库版本等吗

同时,根据您构建的工作流:

  • 为Chris建立一个提要
  • 创建一个活动并将其放在Chris的提要上
  • 给杰克造一个饲料
  • 杰克跟着克里斯的饲料
  • 阅读Jack的提要,期待看到Chris的活动
  • 。。。Jack在关注Chris的feed时需要指定一些要复制的活动,否则Jack只会从那时起看到更新;杰克永远看不到克里斯的“照片:10”。还有第三个可选参数,您可以通过followFeed()发送,该参数指定在开始以下操作时要复制到Jack的提要中的项目数:

    $jack->followFeed('user', 'chris', 100);
    

    或者可以在步骤1和2之间移动步骤4。如果在Chris添加照片之前Jack跟踪Chris,它应该会显示在Jack的提要上。

    我后来发现了一个解决问题的方法。问题是guzzle库正在尝试验证我的证书。因为在转移到生产服务器之前,我需要一种在本地服务器上测试它的方法,所以我必须修改guzzle库中的客户机构造函数,这为我解决了问题

     // file name is Client.php 
    
      public function __construct(array $config = ['verify' => false]) {
        if (!isset($config['handler'])) {
            $config['handler'] = HandlerStack::create();
        }
    
        // Convert the base_uri to a UriInterface
        if (isset($config['base_uri'])) {
            $config['base_uri'] = Psr7\uri_for($config['base_uri']);
        }
    
        $this->configureDefaults($config);
    }
    

    @我是个新手。我遵循了指南,我犯了那个错误。你确定要在“秘密”之后引用单引号吗?这似乎违反了规则。或者这是一个输入错误?请检查您是否启用了带有phpinfo()的openssl,并且库版本是openssl 1.0.11I。我刚刚在生产服务器上试用过,它工作正常。我想知道为什么它不起作用Xampp@michail_w如果你能联系我support@getstream.io我有一些关于您的平台、xampp版本等的后续问题,因此我可以复制这些问题,以帮助您找到解决方案。