Note that there are some explanatory texts on larger screens.

plurals
  1. POerror.USER_REQUIRED generated when attempting to submit Reddit link in objective-c
    text
    copied!<p>I am having a small Reddit API problem here. I am trying to follow the reddit api, as outlined here:</p> <p><a href="https://github.com/reddit/reddit/wiki/API" rel="nofollow">https://github.com/reddit/reddit/wiki/API</a></p> <p>Logging in using a simple NSMutableURLRequest is not a problem:</p> <pre><code>NSString *user = [[NSString alloc]initWithString:[userFld text]]; NSString *passwd = [[NSString alloc]initWithString:[passwordFld text]]; NSString *urlString = [NSString stringWithFormat:@"http://www.reddit.com/api/login/username/?user=%@&amp;passwd=%@", [user stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [passwd stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSURL *url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setHTTPMethod:@"POST"]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; </code></pre> <p>Which gives me a result from which I extract the user mod-hash:</p> <pre><code>4029916%2C2010-04-30T22%3A51%3A52%2C1243925043100000000000000000000000000000 </code></pre> <p>Next I am trying to post, using:</p> <pre><code>NSString *redditUrlString = [NSString stringWithFormat: @"http://www.reddit.com/api/submit/?uh=%@&amp;kind=link&amp;url=%@&amp;sr=%@&amp;title=%@&amp;r=%@&amp;api_type=json", [appDelegate globalUhString], @"www.google.com", @"funny", @"Google.com", @"funny"]; NSURL *url = [NSURL URLWithString:redditUrlString]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; [request setHTTPMethod:@"POST"]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; </code></pre> <p>However, when I extract the JSON response form the data received from this connection, I <em>always</em> receive the error below no matter what I use as the mod-hash:</p> <blockquote> <p>[".error.USER_REQUIRED"]</p> </blockquote> <p>Can someone explain what I have done incorrectly/how I can fix it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload