Giter Site home page Giter Site logo

Comments (11)

nst avatar nst commented on August 18, 2024

I'm not sure I understand your request. Could you please elaborate or give an example? Thank you in advance.

from sttwitter.

tikhop avatar tikhop commented on August 18, 2024

So, for example, take STTwitterOS implementation, scroll down to line #85.

Here you create an error and pass a code equal to '0':

- (void)verifyCredentialsWithSuccessBlock:(void(^)(NSString *username))successBlock errorBlock:(void(^)(NSError *error))errorBlock {
    if([self hasAccessToTwitter] == NO) {
        NSString *message = @"This system cannot access Twitter.";
        NSError *error = [NSError errorWithDomain:NSStringFromClass([self class]) code:0 userInfo:@{NSLocalizedDescriptionKey : message}];
        errorBlock(error);
        return;
    }
    ....
}

Idea is to create a special error code for every particular error in a particular domain.

You can define enum for every particular domain or one for the entire project:

typedef NS_ENUM(NSUInteger, STTwitterOSErrorCode) {
    STTwitterOSErrorCodeCannotAccessTwitter, //This system cannot access Twitter.
        //etc
};

And later you use a code with error and client, who received that error can be used to compare that code.

...
//Sending error
 NSString *message = @"This system cannot access Twitter.";
        NSError *error = [NSError errorWithDomain:NSStringFromClass([self class]) code:STTwitterOSErrorCodeCannotAccessTwitter userInfo:@{NSLocalizedDescriptionKey : message}];
errorBlock(error);
...

...
//Handling error
 [_twitter verifyCredentialsWithSuccessBlock:^(NSString *username) {

        _loginStatusLabel.text = username;

    } errorBlock:^(NSError *error) {
        if(error.code == STTwitterOSErrorCodeCannotAccessTwitter) {
                //Do something special
        }

}];

from sttwitter.

nst avatar nst commented on August 18, 2024

Thank you for this explanation. You're totally right. I'll add errors soon.

from sttwitter.

tikhop avatar tikhop commented on August 18, 2024

You are welcome, thanks for understanding.

from sttwitter.

nst avatar nst commented on August 18, 2024

41c9df9

from sttwitter.

Arsalan90 avatar Arsalan90 commented on August 18, 2024

Hello can you plz help me I'm using STTwitter and using this method for reverse authentication but i'm getting error like this

Error Domain=STTwitterOS Code=0 "This system cannot access Twitter." UserInfo=0xd8f05b0 {NSLocalizedDescription=This system cannot access Twitter.

here what I'm using

  STTwitterAPI *twitter  = [STTwitterAPI twitterAPIWithOAuthConsumerKey:TWITTER_CONSUMER_KEY
                                                           consumerSecret:TWITTER_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) {
                                                                    NSLog(@"oAuthToken: %@, oAuthTokenSecret: %@, userID: %@, screenName: %@", oAuthToken, oAuthTokenSecret, userID, screenName);

                                                                   self.twAuthData = @{@"oAuthToken" : oAuthToken,
                                                                                      @"oAuthTokenSecret" : oAuthTokenSecret,
                                                                                       @"userID" : userID,
                                                                                       @"screenName" : screenName};
                                                                   if ([self.twDelegate respondsToSelector:@selector(loginForNetwork:successful:needsRegistration:)]) {
                                                                        [self.twDelegate loginForNetwork:kNetworkType_TW successful:YES needsRegistration:YES];

}
          } errorBlock:^(NSError *error) {
              NSLog(@"error %@", error);
        }];

       } errorBlock:^(NSError *error) {
           NSLog(@"error %@", error);
             }];

   } errorBlock:^(NSError *error) {
       NSLog(@"error %@", error);
   }];

need your help

from sttwitter.

nst avatar nst commented on August 18, 2024

Are you sure there is a Twitter account set up in iOS Settings? (or OS X Preferences if you're on OS X)

from sttwitter.

SravaniPavuluri avatar SravaniPavuluri commented on August 18, 2024

Hi,
I am getting this error ERror: Error Domain=STTwitterTwitterErrorDomain Code=0 "not recognized." UserInfo=0x7b0c8d90 {NSLocalizedDescription=not recognized.} when I am trying to upload video.
I got Twitter account from my device settings.
Here is my code to upload video:

[_twitter postMediaUploadData:[NSData dataWithContentsOfFile:filePath] fileName:@"Test" uploadProgressBlock:^(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite) {
} successBlock:^(NSDictionary *imageDictionary, NSString *mediaID, NSString *size) {
NSLog(@"Image dictionary: %@", imageDictionary);
NSLog(@"Media ID; %@", mediaID);
NSLog(@"Size; %@", size);
} errorBlock:^(NSError *error) {
NSLog(@"ERror: %@",error);
}];
I am not sure if I am in correct path or not. Please let me know if anything wrong.

Thanks in Advance :)

from sttwitter.

nst avatar nst commented on August 18, 2024

From Twitter API documentation: "Currently, the only type exposed in our entities is photo". So I don't think you can upload videos.

from sttwitter.

userIOS avatar userIOS commented on August 18, 2024

Hi, I need your help. I'm trying different solutions for days :(

I sign in into twitter in my app, I have the authorization. And everything is OK. In that moment I save oAuthToken, oAuthTokenSecret, username... and all the info that I can with the purpose of don't ask again user for his username/password.

So the next time that user go into the app, I just want to post with the twitter's info that I have saved. But I can't "reconnect" or "reopen" the session.

Please, could anyone help me?? I'm really struggling :/

This is what I'm trying:

STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
consumerKey:@"xxx"
consumerSecret:@"xxx"];

    [twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {

        STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];

        [twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {

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

                                                                    // I'm trying to POST on twitter HERE

        } errorBlock:^(NSError *error) {
             NSLog(@"-- ERROR1: %@", error);
        }];

    } errorBlock:^(NSError *error) {
         NSLog(@"-- ERROR2: %@", error);
    }];

And the ERROR that I'm getting is the first one that I control:

ERROR1: Error Domain=STTwitterOS Code=0 "This system cannot access Twitter." UserInfo=0x14d06d30 {NSLocalizedDescription=This system cannot access Twitter.}

from sttwitter.

userIOS avatar userIOS commented on August 18, 2024

Well, I think that the wrong point is when I ask for twitterAPIOSWithFirstAccount. Because I haven't got twitter installed in my phone. So, How could I create an account from the saved info that I have of the first user's authentication??

Thank you in advance!

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.