webvariants / sallycms-twitter
支持Twitter的REST API 1.1
dev-default / 1.x-dev
2014-03-11 08:27 UTC
Requires
- php: >=5.2.0
- j7mbo/twitter-api-php: dev-master
- sallycms/composer-installer: *
- sallycms/sallycms: >=0.8,<0.9
This package is not auto-updated.
Last update: 2020-08-17 10:33:53 UTC
README
一个 SallyCMS 扩展插件
为 Twitter的REST API 1.1 构建
1. 关于
Twitter客户端 是一个扩展插件,为 SallyCMS 构建,以便开发人员轻松访问Twitter API。它使用了两种常见的认证模型: "仅应用" 和 "OAuth签名请求"。
尽管没有实现Twitter API的所有功能(主要是因为不是所有功能都适合在 内容管理系统 中使用),但很容易将其添加到API堆栈中。
本项目采用 MIT许可证。
2. 设置
Twitter客户端 利用 Sally的全局设置 来设置扩展插件。
- 创建一个 Twitter应用(您可能希望使用您的 客户端 Twitter账号来创建此应用)
- 在 Twitter应用配置文件 中创建一个 访问令牌 和 访问令牌密钥,并确保您的 应用 有正确的权限(例如,读取和写入)
- 将以下信息/凭据复制到 Twitter客户端 的全局设置中
- 应用名称
- 应用版本(如果您没有,请使用 "0.1")
- 消费者密钥
- 消费者密钥密钥
- 访问令牌
- 访问令牌密钥
- 缓存持续时间(例如,"120" 表示 2 分钟的数据缓存)
- 保存设置,即可开始使用
3. 使用方法
- 由于Sally使用 PHP Synphony 类似于 "服务容器",首先通过加载
Sly_Core::getContainer()
函数开始,或者如果该函数已经在项目的某个位置加载,则可以跳过此步骤。
**example:**
`$container = sly_Core::getContainer();`
- 接下来,加载任何
twitter-*
容器
**notice:**
the *Twitter Client* is using multiple "service containers", beacause of the amount of functions implemented in the AddOn. Each function is bundled by categories, such as *Timeline*, *Tweets* or *Favorites*
**examples:**
:::php
// single container:
$twitter = $container['twitter-timeline'];
// multiple containers:
$twitter_timeline = $container['twitter-timeline'];
$twitter_tweets = $container['twitter-tweets'];
// or any other twitter-* container
- 现在您可以在所选容器(s)中使用API堆栈
**important:**
Most of the implemented API functions use a variaty of parameters, to costumize the result. Please make you use the right value for the right argument/parameter. Here are some ways to do so:
1. read the PHP file where the *API function* is hosted ([example](https://bitbucket.org/till_lange/twitter-engine-for-sallycms/src/76ddc5d9e0583c7b6bc69c7b34e2835659118b34/lib/Twitter/Requests/Timeline.php?at=default))
2. use the provided *inline documentation* (if you use an IDE)
3. check out the parameters on the [Twitter REST API](https://dev.twitter.com/docs/api/1.1) website
'Not so common' parameters/arguments will be sometimes accepted as *Array*, to avoid to many arguments in a function.
Those paramters are listed under 'optional parameters' in the *inline documentation*.
To use them, write the prefered parameter(s) in array form, at the end of the *API function* call (see 'example 3' in the code example below).
The use of 'optional parameters' is only supported in some *API functions*! Make sure you set up the *Array* with `$key => $value` pairs, where the `$key` is the **correct typed** name of the parameter and the `$value` the parameter value.
**examples:**
:::php
// example 1:
$result = $twitter->home_timeline('20');
// example 2:
$result = $twitter_timeline->user_timeline('', 'twitterapi', '20');
// example 3:
$result = $twitter_tweets->send('Tweet text goes here...', '', array(
'lat' => '52.130807',
'long' => '11.628878'
));
4. 技术规格
- 支持...
- 实现的功能
- 使用两种不同的认证模型("仅应用" 和 "OAuth签名请求"),以提高速率限制
- 许多 API功能,堆叠在12个 "服务容器" 中
- 很容易添加新的 API功能
- 内置 编译器,验证 "常用" 参数
- 使用Sally内置的 Babel Cache
- 需要...
- Sally CMS(0.8或更高版本)
- PHP(5.2.0或更高版本)
- 全局设置(Sally扩展插件)
- 使用...
- Sally CMS(由 WebVariants 构建)
- twitter-api-php 库(由 j7mbo 构建)
- Composer
- cURL
- 许可证
- 本项目采用 MIT许可证
Build @ WebVariants Magdeburg, 2013