7

Ok, so I've currently implemented Facebook login in my app the following way:

I use the official FB framework to login the user. When I login, I get a authentication token, which is sent to my server. I then do another verification of the user (e.g. get "me" from Facebook, using the auth-token), and then return 32 char random key, which is used to identify the user in subsequent API-calls (to my server). An example.

I'm trying to figure out how to do the same with twitter, but I can't understand how to get the oath token in iOS? I have the server-side part working in another app, but no token to verify...

Please advice – is this (the FB way) how I should be doing this, or how would you go about the verification process?

Community
  • 1
  • 1
Arvid Janson
  • 1,034
  • 10
  • 10

3 Answers3

1

There's a good article at dev.twitter.com describing exactly that. Basically you'll have to first get a special request token by setting the x_auth_mode parameter to the value reverse_aut and then get the proper access token by sending what you got in the first step as x_reverse_auth_parameters.

mb21
  • 34,845
  • 8
  • 116
  • 142
1

Sean Cook, engineer @ Twitter has a github repo with a simple app that do exactly what you are trying to do, I'using this code in my app and it works like a charm.

oiledCode
  • 8,589
  • 6
  • 43
  • 59
-2

If you are going for an iOS 5 solution, you can import this into your header file

 #import < Twitter/TWTweetComposeViewController.h >

and then in the .m file where you want to authenticate

if ([TWTweetComposeViewController canSendTweet])
{

            TWTweetComposeViewController* twc = [[TWTweetComposeViewController alloc] init];
            [twc addImage:uiImage
            [self presentModalViewController:twc animated:YES];
            twc.completionHandler = ^(TWTweetComposeViewControllerResult result) 
            {

                if (result == TWTweetComposeViewControllerResultCancelled)
                    NSLog(@"Tweet compostion was canceled.");
                else if (result == TWTweetComposeViewControllerResultDone)
                    NSLog(@"Tweet composition completed.");

                // Dismiss it
                [self dismissModalViewControllerAnimated:YES];
            };
            [twc release];
        } else
        {
            //can't tweet

        } 

You can also add URLs, text and other sorts of information.

Edit: You can find a tutorial on adding the needed Library to your project here, https://dev.twitter.com/docs/ios/how-add-twitter-framework-your-ios-project

Divyu
  • 1,325
  • 9
  • 21
Ryan Murphy
  • 356
  • 2
  • 9