How to use Oauth properly

2020-07-25 09:40发布

问题:

I haven't made much progress, so rather then look for an answer to the error stated in my original question, I think my problem would best be solved by some overall instructions on how to use Oauth properly. Please look below to question reformulated.


ORIGINAL QUESTION

I'm using the cocoa-wrapper api for soundcloud on my iPhone app. I'm trying to post with the code below, but get an error 422. I believe it has to do with the string @"x-myapplicationurlscheme://connect", but the url's given to me by soundcloud look like this:

 https://soundcloud.com/connect
 https://api.soundcloud.com/oauth2/token
 http://api.soundcloud.com/oauth/request_token
 http://api.soundcloud.com/oauth/access_token
 http://soundcloud.com/oauth/authorize

and I don't think they need to be plugged into the Dictionary below. On the other hand I don't know what else to put there. Also, it seems to me there were some errors in the original sample code which I have corrected, but maybe erroneously.

 [api performMethod:@"POST"
     onResource:@"connections"
 withParameters:[NSDictionary dictionaryWithObjectsAndKeys:
                                             @"service", @"twitter",
                                             @"x-myapplicationsurlscheme://connection", @"redirect_uri",
                                             @"touch", @"display", //optional, forces services to use the mobile auth page if available
                                             nil]
        context:nil
       userInfo:nil];

So the question is....

How do I use this POST correctly? What am I doing wrong that gives the error 422?


QUESTION REFORMULATED

What I'm trying to accomplish is to have the user press a button to be able to connect their Soundcloud account to Facebook. This way they can have audio posted to FB automatically after it is uploaded to Soundcloud.

Below are screen shots of my Soundcloud configuration page and places within my app that need setting up. I believe that it is just a matter of plugging in the right the values in the right place, but I'm not sure exactly how to do this. Help, please!

Also, the last screenshot shows what happens when the user presses the Facebook connect button. Does this look right?

Thanks so much,

回答1:

Okay so Chapter 21 Web Services of The Big Nerd Ranch Guide to iPhone Programming seems to have help clear things up quite a bit.

I guess this question was too vast to be answered. I thought I could plug in some values and a couple of lines of code and that would be it. Guess not.



回答2:

Declaration of performMethod method doesn't contain userInfo parameter, contains connectionDelegate instead. Are you sure about your code?