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?

3 Answers 3

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.

1
+50

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.

-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

1
  • How does this answer the question?
    – Moxy
    Jun 15, 2013 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.