简体   繁体   English

如何使用划线员在Grails中为Twitter实现仅应用程序身份验证?

[英]How to implement application-only authentication for twitter in Grails using scribe?

Earlier i was using GET search/tweets of Twitter API 1.0 To get tweets according to #tags in Grails 早些时候我使用的是Twitter API 1.0的GET搜索/推文,根据Grails中的#tags获取推文

Map jsonMap = grails.converters.JSON.parse(new URL('http://search.twitter.com/search.json?q=%23' + URLEncoder.encode(tag) + '&offset=' + offset + 'result_type=mixed&lang=en&page=' + page).text)

But due to change in Twitter API version 1.1 now the above call requires Authentication. 但是由于Twitter API版本1.1中的更改​​,上述调用需要身份验证。

I want to fetch tweets on behalf of Application(Authentication) not by user Authentication. 我想代表应用程序(身份验证)而不是用户身份验证来获取推文。

Is this possible? 这可能吗?

I came across application-only-auth but unable to implement it. 我遇到了仅应用程序身份验证,但是无法实现它。

https://dev.twitter.com/docs/auth/application-only-auth https://dev.twitter.com/docs/auth/application-only-auth

How to implement above using scribe API in Grails. 如何在Grails中使用scribe API实施上述操作。

I have done like this and it worked for me. 我已经做到了,它对我有用。

 OAuthService service = new ServiceBuilder().provider(TwitterApi.class).apiKey(grailsApplication.config.oauth.providers.twitter.key).apiSecret(grailsApplication.config.oauth.providers.twitter.secret).build()
            OAuthRequest request = new OAuthRequest(Verb.GET, 'https://api.twitter.com/1.1/search/tweets.json?q=%23' + URLEncoder.encode(tag) + '&count=100&result_type=mixed&lang=en');
            Token accessToken = new Token(grailsApplication.config.oauth.providers.twitter.accessToken, grailsApplication.config.oauth.providers.twitter.accessSecret)
            service.signRequest(accessToken, request);
            Response response = request.send();
            JSONElement jsonMap = grails.converters.JSON.parse(response.getBody());

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

相关问题 Twitter4j-通过仅应用程序身份验证分配的搜索/推文请求 - Twitter4j - Requests allotted via application-only auth for search/tweets 使用scribe进行Facebook身份验证时如何实例化验证程序 - how to instantiate verifier when using scribe for facebook authentication 在Twitter中使用Scribe库for Oauth和回调网址 - Using Scribe library for Oauth in Twitter with callback url 带有Scribe的Java Twitter客户端(第一次使用它)。 如何发布状态? - Java Twitter Client with Scribe (1st time using it). How to post status? twitter应用程序仅使用twitter4j验证java android - twitter application only authentication java android with twitter4j 如何使用 Scribe 进行 POST 调用并在 Java 中获取具有 OAuth 1.0 身份验证的数据? - How to make a POST call using Scribe and fetch data having OAuth 1.0 Authentication in Java? OAuth 2和Grails上的抄写员 - OAuth 2 & Scribe on Grails Twitter API使用仅应用程序身份验证获取Tweet返回HTTP状态代码401 - Twitter API to get Tweets using Application Only Authentication returns HTTP Status Code 401 使用Twitter Streaming Api时抄写Java错误 - Scribe java error while using Twitter Streaming Api 使用HttpClient 4.2.1为Java Twitter应用程序设置OAuth身份验证 - Setting up OAuth authentication for a Java Twitter application using HttpClient 4.2.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM