嗨,我需要从我的应用程序发送LinkedIn连接请求。我引用此链接,但我仍然得到错误。
- 按以下代码发送请求**
NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/mailbox"];
OAMutableURLRequest *request =
[[OAMutableURLRequest alloc] initWithURL:url
consumer:oAuthLoginView.consumer
token:oAuthLoginView.accessToken
callback:nil
signatureProvider:[[OAHMAC_SHA1SignatureProvider alloc] init]];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSDictionary *temp=[[NSDictionary alloc]initWithObjectsAndKeys:@"/people/email=test@test.com",@"_path",@"Test",@"first-name",@"Testing",@"last-name", nil];
NSDictionary *temp2=[[NSDictionary alloc] initWithObjectsAndKeys:temp,@"person",nil];
NSArray *arr2=[[NSArray alloc]initWithObjects:temp2, nil];
NSDictionary *value=[[NSDictionary alloc]initWithObjectsAndKeys:arr2,@"values", nil];
NSDictionary *dict3=[[NSDictionary alloc]initWithObjectsAndKeys:@"friend",@"connect-type",nil];
NSDictionary *dict4=[[NSDictionary alloc] initWithObjectsAndKeys:dict3,@"invitation-request", nil];
NSDictionary *dict=[[NSDictionary alloc]initWithObjectsAndKeys:dict4,@"item-content",@"Say yes!",@"body",@"Invitation to connect.",@"subject",value,@"recipients", nil];
NSString *updateString = [dict JSONString];
[request setHTTPBodyWithString:updateString];
[request setHTTPMethod:@"POST"];
OADataFetcher *fetcher = [[OADataFetcher alloc] init];
[fetcher fetchDataWithRequest:request
delegate:self
didFinishSelector:@selector(postUpdateApiCallResult1:didFinish:)
didFailSelector:@selector(postUpdateApiCallResult1:didFail:) withPrepare:NO];
- OAD数据提取器. m**
- (void)fetchDataWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector withPrepare:(BOOL)isPrepare
{
[request release];
request = [aRequest retain];
delegate = aDelegate;
didFinishSelector = finishSelector;
didFailSelector = failSelector;
if (isPrepare)
[request prepare];
connection = [[NSURLConnection alloc] initWithRequest:aRequest delegate:self];
}
我在下面遇到错误
<error>
<status>401</status>
<timestamp>1399885201227</timestamp>
<request-id>YTU5250BQI</request-id>
<error-code>0</error-code>
<message>Unknown authentication scheme</message>
</error>
o授权登录视图. m
OARequestParameter *nameParam = [[OARequestParameter alloc] initWithName:@"scope"
value:@"r_fullprofile+r_contactinfo+r_emailaddress+r_network+rw_nus+w_messages"];
NSArray *params = [NSArray arrayWithObjects:nameParam, nil];
[request setParameters:params];
OARequestParameter * scopeParameter=[OARequestParameter requestParameter:@"scope" value:@"r_fullprofile r_contactinfo r_emailaddress r_network rw_nus w_messages"];
这些是我给出的previlages。我分享文本和从LinkedIn获得个人资料信息,所有工作正常,但发送请求不工作。
1条答案
按热度按时间xmjla07d1#
像这样编辑
NSURL *url = [带有字符串的NSURL URL:@”http://api.linkedin.com/v1/people/~/mailbox“];
你只是混淆了这个。我只是在你的参考链接做了一些改变,它的工作原理就像这样使用。我希望它会对你有帮助。