Have you applied for xAuth access, oAuth is enabled for clients by
default but xAuth you have to apply for.

On Mar 1, 12:53 pm, Battan Ror <[email protected]> wrote:
> Hi
>
> I am using MGTwitterEngine in Iphone application
>
> But I am getting error in log of function
> - (void)requestFailed:(NSString *)connectionIdentifier withError:
> (NSError *)error
> {
>     NSLog(@"Twitter Request failed for connectionIdentifier = %@,
> error = %@ (%@)",
>           connectionIdentifier,
>           [error localizedDescription],
>           [error userInfo]);
>
> }
>
> Error Log
>
> Twitter Request failed for connectionIdentifier =
> 8E192CD3-35E5-46C8-86E9-1EADEE38B6E8, error = The operation couldn’t
> be completed. (HTTP error 401.) ({
>     body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<hash>\n
> <request>/oauth/access_token</request>\n  <error>Client application is
> not permitted to use xAuth.</error>\n</hash>\n";
>     response = "<NSHTTPURLResponse: 0x603b6a0>";
>
> })
>
> following code in controller class
> -(IBAction)twitterBtnAct:(id)sender{
>     // Put your Twitter username and password here:
>     NSString *username = @"myusername";
>     NSString *password = @"mypassword";
>
>     NSString *consumerKey = @"b2jD5AXJewSNfmCBfzvlw";
>     NSString *consumerSecret =
> @"ceqEECJalqtVUnxl8sNQxrh5dXGUvo9cg4HxKNn6g";
>
>     // Most API calls require a name and password to be set...
>     if (! username || ! password || !consumerKey || !consumerSecret) {
>         NSLog(@"You forgot to specify your username/password/key/
> secret in AppController.m, things might not work!");
>                 NSLog(@"And if things are mysteriously working without the 
> username/
> password, it's because NSURLConnection is using a session cookie from
> another connection.");
>     }
>
>     // Create a TwitterEngine and set our login details.
>     twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
>     [twitterEngine setUsesSecureConnection:NO];
>     [twitterEngine setConsumerKey:consumerKey secret:consumerSecret];
>     // This has been undepreciated for the purposes of dealing with
> Lists.
>     // At present the list API calls require you to specify a user
> that owns the list.
>     [twitterEngine setUsername:username];
>
>     [twitterEngine getXAuthAccessTokenForUsername:username
> password:password];
>
> }
>
> #pragma mark Twitter methods
> #pragma mark MGTwitterEngineDelegate methods
> - (void)accessTokenReceived:(OAToken *)aToken forRequest:(NSString
> *)connectionIdentifier
> {
>     NSLog(@"Twitter Access token received! %@",aToken);
>     token = [aToken retain];
>     [self runTests];
>
> }
>
> - (void)requestSucceeded:(NSString *)connectionIdentifier
> {
>     NSLog(@"Twitter Request succeeded for connectionIdentifier = %@",
> connectionIdentifier);
>
> }
>
> - (void)statusesReceived:(NSArray *)statuses forRequest:(NSString
> *)connectionIdentifier
> {
>     NSLog(@"Twitter Got statuses for %@:\r%@", connectionIdentifier,
> statuses);
>
> }
>
> - (void)directMessagesReceived:(NSArray *)messages forRequest:
> (NSString *)connectionIdentifier
> {
>     NSLog(@"Twitter Got direct messages for %@:\r%@",
> connectionIdentifier, messages);
>
> }
>
> - (void)userInfoReceived:(NSArray *)userInfo forRequest:(NSString
> *)connectionIdentifier
> {
>     NSLog(@"Twitter Got user info for %@:\r%@", connectionIdentifier,
> userInfo);
>
> }
>
>

-- 
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group: 
http://groups.google.com/group/twitter-development-talk

Reply via email to