Giter Site home page Giter Site logo

Direct Messaging problem about sttwitter HOT 5 CLOSED

nst avatar nst commented on July 18, 2024
Direct Messaging problem

from sttwitter.

Comments (5)

nst avatar nst commented on July 18, 2024

You should login with the iOS Twitter account and perform reverse authentication with your own consumer tokens. You will end up with access tokens that will let your own application access direct messages. Let me know if it doesn't work.

from sttwitter.

muhammad786 avatar muhammad786 commented on July 18, 2024

Hello,

Thanks for your reply, So here is the code that i am using for fetching direct messages of any user that is login currently

-(void) getDirectMessages
{
STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
consumerKey:ConsumerKey
consumerSecret:ConsumerSecret];

[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:ConsumerKey
                                                                                                                  consumerSecret:ConsumerSecret
                                                                                                                      oauthToken:oAuthToken
                                                                                                                oauthTokenSecret:oAuthTokenSecret];

                                                                 [x verifyCredentialsWithSuccessBlock:^(NSString *username)
                                                                  {
                                                                      [x getDirectMessagesSinceID:nil count:100 successBlock:^(NSArray *messages)
                                                                       {
                                                                           NSLog(@"%@",messages);
                                                                           [AMISharedMessageResources getSharedMessageResources].rawRecentMessages = [NSMutableArray arrayWithArray:messages];//messages;
                                                                           [self parseRecentMessages];
                                                                           // ...
                                                                       } errorBlock:^(NSError *error) {

                                                                           if ([self.delegate respondsToSelector:@selector(recentMessagesFetchingError)]) {
                                                                               [self.delegate recentMessagesFetchingError];
                                                                           }

                                                                           NSLog(@"%@",error);
                                                                           // ...
                                                                       }];

                                                                  } errorBlock:^(NSError *error) {
                                                                      if ([self.delegate respondsToSelector:@selector(recentMessagesFetchingError)]) {
                                                                          [self.delegate recentMessagesFetchingError];
                                                                      }

                                                                      NSLog(@"%@",error);
                                                                  }];


                                                             } errorBlock:^(NSError *error) {
                                                                 if ([self.delegate respondsToSelector:@selector(recentMessagesFetchingError)]) {
                                                                     [self.delegate recentMessagesFetchingError];
                                                                 }

                                                                 NSLog(@"%@",error);
                                                             }];

     } errorBlock:^(NSError *error) {

         if ([self.delegate respondsToSelector:@selector(recentMessagesFetchingError)]) {
             [self.delegate recentMessagesFetchingError];
         }

         NSLog(@"%@",error);
     }];

 } errorBlock:^(NSError *error) {

     if ([self.delegate respondsToSelector:@selector(recentMessagesFetchingError)]){
         [self.delegate recentMessagesFetchingError];
     }

     NSLog(@"%@",error);
 }];    

}

And i am using the consumer secret and consumer key of my own twitter App(that i developed using my own twitter credentials), so problem is that if i login on device using my own account then this application/code fetches my Direct messages but if i login on device using any other twitter account then this application/code showing this Error

Error Domain=STHTTPRequest Code=93 "This application is not allowed to access or delete your direct messages." UserInfo=0xaaa2250 {NSLocalizedDescription=This application is not allowed to access or delete your direct messages.}

As per my understanding through this code i can only access my own direct messages. So if my application want to access any other user direct messages on behalf of his account then we have to get twitter approval for "XAUTH" that's why i submitted request to twitter but they rejected by saying may be some other Authentication is more suitable for you.

Or please guide me if any other authentication is more suitable for my app other then reverse authentication. As i m already facing the Rest api limit issues because my app have direct message chat system as well.

Thanks

Thanks

from sttwitter.

muhammad786 avatar muhammad786 commented on July 18, 2024

As per Twitter i have to first implement complete web based Auth flow for "getting a Special Request Token" and after it i will request for "Access Token " for Actual reverse authentication and then my app can access any users Direct messages then i would not face this issues for getting any user direct messages

"Error Domain=STHTTPRequest Code=93 "This application is not allowed to access or delete your direct messages." UserInfo=0xaaa2250 {NSLocalizedDescription=This application is not allowed to access or delete your direct messages.}"

If i am right then how can i do the web based Auth flow using your library and will process further for getting the any user direct message and not only mine.

Thanks

from sttwitter.

nst avatar nst commented on July 18, 2024

I haven't tested yet but I think your users should be able to access their direct messages if:

  • you use the web based authentication, as in the STTwitter iOS demo project
  • you setup your Twitter application permissions to access direct messages

Let me know it it works or not.

from sttwitter.

nst avatar nst commented on July 18, 2024

I just tested the methodology I advised in my last message and it works, so:

  1. make sure your Twitter app is set to access direct messages (you don't need Twitter's approval for that)
  2. authenticate your user with web-based authentication (as in STTwitter iOS demo project)
  3. perform reverse auth. and let any user access their direct messages https://gist.github.com/nst/8052682

photo

from sttwitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.