连接getstream php出错



我遵循https://getstream.io/get_started/?language=php的示例来理解getstream io是如何工作的。我遇到了一个错误,把我弄糊涂了。

 require_once './vendor/autoload.php';
 $client = new GetStreamStreamClient('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);

在我的作曲家。我做了这个

       "require": {
        "get-stream/stream": "2.2.8"
        }

我在windows上的本地主机上尝试了上面的代码,但得到了这个错误

Fatal error: Uncaught exception 'GuzzleHttpExceptionConnectException'     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:xampphtdocsCorpersMatevendorguzzlehttpguzzlesrcHandlerCurlFactory.php on line 186
 GuzzleHttpExceptionConnectException: 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:xampphtdocsCorpersMatevendorguzzlehttpguzzlesrcHandlerCurlFactory.php on line 186
有什么想法吗?

你应该提供指南-我们必须先注册才能获得它,这是不可能发生的。

将第二行改为

$client = new GetStreamStreamClient(KEY, SECRET);

我后来找到了一个解决问题的方法。问题是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'] = Psr7uri_for($config['base_uri']);
    }
    $this->configureDefaults($config);
}

我将深入研究为什么这在Xampp上不起作用。你能给我们发送你的cURL选项,库版本等吗?

同时,基于您构建的工作流程:

  1. 为Chris构建feed
  2. 建立一个活动并把它放在Chris的feed上
  3. 为Jack构建feed
  4. Jack关注Chris的feed
  5. 阅读Jack的feed并期望看到Chris的活动

…当关注Chris的feed时,Jack需要指定一些活动来复制,否则Jack只能看到从那个点开始的更新;杰克永远不会看到克里斯发来的"第10张照片"。您可以通过followFeed()发送第三个可选参数,该参数指定当您开始关注时要复制多少条目到Jack的提要:

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

或者你可以把步骤4移到步骤1和步骤2之间。如果Jack在Chris添加照片之前关注了Chris,照片应该会显示在Jack的feed上。