本文介绍了使用SLRequest iOS访问Twitter Direct消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用SLrequest访问直接消息。我使用Twitter的Reverse oAuth获得了oAuthToken和oAuthToken Secret。现在我需要知道如何从网址。我尝试添加oAuthToken和oAuthTokenSecret部分SLRequest,但我得到同样的错误,此应用程序不允许访问或删除您的直接消息。 oAuthToken和oAuthTokenSecret有什么用?如何让直接消息适用于应用程序?我已将应用程序的访问级别更改为读取,写入和直接消息。请帮助我解决问题。

I need to access the Direct Messages using SLrequest. I got the oAuthToken and oAuthToken Secret using the Reverse oAuth of twitter. Now I need to know how to fetch the direct messages from the https://api.twitter.com/1.1/direct_messages.json url. I have tried adding oAuthToken and oAuthTokenSecret part of SLRequest but I get the same error, "This application is not allowed to access or delete your direct messages". What is the use of oAuthToken and oAuthTokenSecret? How to make direct messages work for the app? I have changed the access level of application to "Read, write, and direct messages". Please help me in solving the problem.

推荐答案

以下是如何访问iOS默认Twitter帐户的直接消息。

Here is how to access direct messages for the iOS default Twitter account.

此示例使用库,该库在内部使用SLRequest进行阶段2和a第1阶段的自定义制作请求。

This example uses the STTwitter library, which internally uses SLRequest for phase 2 and a custom crafted request for phase 1.

NSString *CONSUMER_KEY = @"";
NSString *CONSUMER_SECRET = @"";

STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
                                                          consumerKey:CONSUMER_KEY
                                                       consumerSecret:CONSUMER_SECRET];

[twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {

    STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];

    [twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {

        [twitterAPIOS postReverseAuthAccessTokenWithAuthenticationHeader:authenticationHeader
                                                            successBlock:^(NSString *oAuthToken,
                                                                           NSString *oAuthTokenSecret,
                                                                           NSString *userID,
                                                                           NSString *screenName) {

                                                                STTwitterAPI *x = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
                                                                                                                    consumerKey:CONSUMER_KEY
                                                                                                                 consumerSecret:CONSUMER_SECRET
                                                                                                                     oauthToken:oAuthToken
                                                                                                               oauthTokenSecret:oAuthTokenSecret];

                                                                [x verifyCredentialsWithSuccessBlock:^(NSString *username) {

                                                                    [x getDirectMessagesSinceID:nil count:10 successBlock:^(NSArray *messages) {
                                                                        // ...
                                                                    } errorBlock:^(NSError *error) {
                                                                        // ...
                                                                    }];

                                                                } errorBlock:^(NSError *error) {
                                                                    // ...
                                                                }];


                                                            } errorBlock:^(NSError *error) {
                                                                // ...
                                                            }];

    } errorBlock:^(NSError *error) {
        // ...
    }];

} errorBlock:^(NSError *error) {
    // ...
}];

这篇关于使用SLRequest iOS访问Twitter Direct消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 06:33