Send a tweet by creating STTwitterAPI Object

160 Views Asked by At

I'm using STTwitter library. And I'm trying to send a tweet this way:

[twitterObject postStatusUpdate:@"Testing!!"
                                   inReplyToStatusID:nil
                                            latitude:nil
                                           longitude:nil
                                             placeID:nil
                                  displayCoordinates:nil
                                            trimUser:nil
                                        successBlock:^(NSDictionary *status) {
                                            NSLog(@"-- screenName: %@", @"OK sended");

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

So, I want to create my "twitterObject" with the tokens that I save before. Because I want that the users just authenticate in the app once. For that I save the tokens, and that is the reason why I instantiate STTwitterAPI.

I do this way:

 STTwitterAPI *twitter =
[STTwitterAPI twitterAPIWithOAuthConsumerName:nil
                                  consumerKey:@"xxx"
                               consumerSecret:@"xxx"
                                   oauthToken:[defaults objectForKey:@"twitterToken"]
                             oauthTokenSecret:[defaults objectForKey:@"twitterOauthTokenSecret"]
];
twitter.userName = [defaults objectForKey:@"twitterUsername"];

Is that OK??? Because I can't send my tweet.

I have this ERROR: 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'

Pleaseeee, can anyone help me???

2

There are 2 best solutions below

0
On
  1. You have to verify the credentials before you can actually send a tweet.

  2. Saving the credentials depends on how you want to connect (OAuth, XAuth, iOS Account, ...)

0
On

You can try this library i wrote for my own app https://github.com/narup/PSTwitterEngine