views:

70

answers:

1

Hi there, I try to develop a app that use OauthConsumer for connection with LinkedIN. All work fine, I can extract the user data but when I want to update User status I've status error 401 with message [unauthorized]. I've the access token, this is the code:

NSURL *url = [NSURL URLWithString:@"https://api.linkedin.com/v1/people/~/current-status"];
OAMutableURLRequest *request1 = [[OAMutableURLRequest alloc] initWithURL:url
                 consumer:consumer
                    token:accToken// 
                    realm:nil   // 
                 signatureProvider:nil] ; // 
NSLog(@"mytoken%@",[request1 token]);

[request1 setHTTPMethod:@"PUT"];

[request1 setHTTPBodyWithString:@"<?xml version=''1.0'' encoding=''UTF-8'?><current-status>is setting their status using the LinkedIn API.</current-status>"]; 

OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request1
    delegate:self
    didFinishSelector:@selector(status:didFinishWithData:)
    didFailSelector:@selector(status:didFailWithError:)];

Any ideas??? Plese help me!!!!!! :( tnx

A: 

OK, the rigth code is the next:

NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/shares"];
OAMutableURLRequest *request1 = [[OAMutableURLRequest alloc] initWithURL:url
                                                                consumer:consumer
                                                                   token:accToken
                                                                   realm:nil
                                                       signatureProvider:nil];  
NSLog(@"mytoken%@",[request1 token]);




[request1 setHTTPShouldHandleCookies:NO];
[request1 setValue:@"text/xml;charset=UTF-8" forHTTPHeaderField:@"Content-Type"];

[request1 setHTTPMethod:@"POST"];
[request1 prepare];
[request1 setHTTPBody:[NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/status.xml", [[ NSBundle mainBundle] resourcePath]]]];


NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request1 delegate:self];
[connection start];
digitalPad