使用 oauth 令牌签署 twitter 休息请求 [英] sign twitter rest request with oauth token
问题描述
我有一个使用 twitter rest API 的应用.一切正常,但我们遇到了速率限制,因此我们需要使用 oAuth 进行身份验证.我有 oauth 令牌和秘密.它不是面向消费者的应用,我们只需要使用此令牌和密码进行身份验证.
I have an app using the twitter rest API. Everything is working fine but we're bumping into rate limits so we need to authenticate using oAuth. I have the oauth token and secret. It's not a consumer facing app and we will only need to authenticate using this token and secret.
我的问题是如何在其余请求中包含令牌和秘密以进行身份验证?
My question is how to include the token and secret in the rest request to authenticate?
有很多关于如何获取令牌和秘密的文档,但我找不到任何关于如何使用它们的文档.
There's a plenty of documentation on how to obtain the token and secret but I can't find any on how to use them.
推荐答案
使用 TwitterOAuth PHP 库吧就这么简单:
<?php
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$content = $connection->get('account/verify_credentials');
演示 index.php 中还有更多示例请求.
There are several more example requests in the demo index.php.
这篇关于使用 oauth 令牌签署 twitter 休息请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!