我使用OAuthStarter工具包訪問LinkedIn API。我成功獲取權限的訪問令牌。無法使用LinkedIn的OAuth入門工具包共享
rw_ns
r_basicprofile
r_fullprofile
有可能獲取配置文件的詳細信息,以及分享僅意見和同時共享URL或圖片的說明等。我使用以下代碼:
-(void)postUpdate
{
NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/shares"];
OAMutableURLRequest *request =
[[OAMutableURLRequest alloc] initWithURL:url
consumer:[self getConsumer]
token:self.accesstoken
callback:nil
signatureProvider:nil];
NSDictionary *update = [[NSDictionary alloc] initWithObjectsAndKeys:
[[NSDictionary alloc]
initWithObjectsAndKeys:
@"anyone",@"code",nil], @"visibility",
@"title goes here",@"title",
@"comment goes here", @"comment",
@"description goes here",@"description",
@"www.google.com",@"submitted-url",
@"http://economy.blog.ocregister.com/files/2009/01/linkedin-logo.jpg",@"submitted-image-url",
nil];
[request setValue:@"json" forHTTPHeaderField:@"x-li-format"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSString *updateString = [update JSONString];
[request setHTTPBodyWithString:updateString];
[request setHTTPMethod:@"POST"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(postUpdateApiCallResult:didFinish:)
didFailSelector:@selector(postUpdateApiCallResult:didFail:)];
}
但我得到一個錯誤的反應如下:
2012-10-09 18:27:29.906 SocialConnectTest[9460:19a03] data {
"errorCode": 0,
"message": "Invalid xml {Expected elements '[email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1 [email protected]://api.linkedin.com/v1' instead of '[email protected]://api.linkedin.com/v1' here in element [email protected]://api.linkedin.com/v1}",
"requestId": "W2G7WJDHOJ",
"status": 400,
"timestamp": 1349787449685
}
而且我不知道是什麼問題。任何人都可以幫我解決這個問題嗎?
它看起來像端點期待XML,即使您指定JSON。您是否嘗試過推送XML以查看錯誤是否相同? –