stavarengo/twitter-php-api-client

PHP 客户端库,用于 https://developer.twitter.com API

v0.0.6 2019-03-14 20:54 UTC

This package is auto-updated.

Last update: 2024-09-15 11:01:08 UTC


README

PHP 客户端库,用于 https://developer.twitter.com API

如果你对 Twitter 的 PHP API 感兴趣,那么这就是你的库 :)

关于它

  • 仅依赖 PSR。
  • 可选使用缓存以减少请求并加快响应速度。
  • 你可以将它用于任何应用程序,无论它是否使用 PSR-11 工厂。
  • 它应该非常易于使用,因为我尽量使所有源代码都有良好的文档。

安装

通过 composer 安装。

composer require stavarengo/twitter-php-api-client:^0.0

基本用法 - 更完整的文档即将到来

  • 直接使用(不使用工厂)。

    $client = new \Sta\TwitterPhpApiClient\TwitterClient(null);
    
    $authResponse = $client->postOauth2Token($consumerKey, $consumerSecret);
    $response = $client->getUsersShow('@username', false, $authResponse->getEntityBearerToken());
    
    var_dump($response->hasError() ? $response->getEntityError() : $response->getEntityUser());
  • 使用我们的默认工厂(PSR-11)。

    $client = $container->get(\Sta\TwitterPhpApiClient\Client::class)
    
    $authResponse = $client->postOauth2Token($consumerKey, $consumerSecret);
    $response = $client->getUsersShow('@username', false, $authResponse->getEntityBearerToken());
    
    var_dump($response->hasError() ? $response->getEntityError() : $response->getEntityUser());