简体   繁体   English

用oauth令牌签署twitter rest请求

[英]sign twitter rest request with oauth token

I have an app using the twitter rest API. 我有一个使用twitter rest API的应用程序。 Everything is working fine but we're bumping into rate limits so we need to authenticate using oAuth. 一切正常,但我们正在进入速率限制,所以我们需要使用oAuth进行身份验证。 I have the oauth token and secret. 我有oauth令牌和秘密。 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. 有很多关于如何获取令牌和秘密的文档,但我找不到任何关于如何使用它们的文档。

Using the TwitterOAuth PHP library it is as simple as this: 使用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');

There are several more example requests in the demo index.php . 演示版index.php中还有几个示例请求。

Twitter文档链接到一些可用于完成OAuth身份验证的PHP OAuth库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM