danvin-test/twitter-activity

简单的 PHP Twitter 用户活动检查器

1.1 2018-06-08 17:22 UTC

This package is not auto-updated.

Last update: 2024-09-22 06:35:35 UTC


README

这个小型的网络应用将用户的 Twitter 昵称作为参数,并返回一个包含 "小时 -> 推文数量" 的 JSON 编码数组,以确定用户在一天中哪个小时最活跃。它还提供了 Silex 路由的演示。

要求

  1. PHP 7.1.3 或更高版本
  2. 启用 PHP CURL 模块
  3. 启用 mod_rewrite 模块(仅用于 Web 服务器上使用)

安装

  1. 安装 Composer

     curl -s https://getcomposer.org/installer | php
    
  2. 执行

     php composer.phar create-project danvin-test/twitter-activity project_name
    

配置

Twitter API 凭据

编辑位于项目根目录中的 config.json,以设置您的 Twitter API 凭据

注意事项:此网络应用使用 statuses/user_timeline Twitter API。在 config.json 的 twitterRequestSettings 部分下提供了高级配置。

.htaccess

如果您的网站不在网站根目录级别,您将需要取消注释 RewriteBase 语句并调整路径以指向您的目录,从网站根目录相对位置。更多信息请参阅 Silex Web 服务器配置 页面

使用

该应用程序有 3 个端点

  1. "/" - 以文本形式响应 "尝试 /hello/:name"
  2. "/hello/Daniel" - 以文本形式响应 "Hello Daniel"
  3. "/histogram/Ferrari" - 以 JSON 编码的数组形式响应,显示每天每小时的推文数量。最活跃的时间将在数组的顶部显示。

命令行界面

php index.php GET /                            
php index.php GET /hello/Daniel
php index.php GET /histogram/Ferrari

Web 服务器

https:///
https:///hello/daniel
https:///histogram/Ferrari

运行测试

  1. 确保您已安装 PHPUnit 安装

  2. 要执行测试,请导航到您的项目文件夹并运行

     phpunit
    

构建于

  1. Silex
  2. twitter-api-php