2010-08-31 42 views
0

我嘗試開發一個應用程序,它使用OauthConsumer與LinkedIN進行連接。 一切正常,我可以提取用戶數據,但是當我想更新用戶狀態時,我的狀態錯誤401與消息[未授權]。 我已經訪問令牌,這是代碼:Oauth Consumer - LinkedIN UPDATE STATUS

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:)]; 

任何想法?請幫助我!!!!!! :( TNX

回答

2

確定,分辯代碼是下一個:

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];