LinkedIn邀请API错误401 [未经授权] -iPhone sdk [英] LinkedIn Invitation API error 401 [unauthorized]-iPhone sdk

查看:124
本文介绍了LinkedIn邀请API错误401 [未经授权] -iPhone sdk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OAuth-Sample-Client代码通过Linked Invitation API从电子邮件地址发送邀请。
我创建了与开发者网站中描述的相同的主体,但是现在我收到了401的错误,我已经搜索了很多内容,但没有得到任何解决方案让我从任何网站中删除它或论坛。
我的回复如下。

I am using OAuth-Sample-Client code to send invitation from email address via Linked Invitation API. I have created the same body as described in developer site,but right now I am getting error of 401,I have searched a lot of on it but didn't get any solution which get me out of it from any site or forum. My response is as below.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
  <status>401</status>
  <timestamp>1351159386437</timestamp>
  <request-id>YX4NRU3S7J</request-id>
  <error-code>0</error-code>
  <message>[unauthorized]. OAU:ron8e8nko3te|e0a96317-dfdc-44fb-b427-5655e02f97ed|*01|*01:1351159294:dRCDN6b3K9F/mwWAaByKZQPgeVw=</message>
</error>

这里我的json字符串是这样的:

Here my json string would be like this:


{body:Say yes!,subject:邀请
connect。,recipients:{values:[{person :{ 第一名: 测试, 最后的名称: 测试, _路径: / people/email=test@test.com}}]}, 项内容:{ 邀请请求:{connect-type:friend}}}

{"body":"Say yes!","subject":"Invitation to connect.","recipients":{"values":[{"person":{"first-name":"test","last-name":"test","_path":"/people/email=test@test.com"}}]},"item-content":{"invitation-request":{"connect-type":"friend"}}}

我使用了以下代码发送邀请。

I have used the code as below to send Invitation.

- (IBAction)postButton_TouchUp:(UIButton *)sender
{    
    [statusTextView resignFirstResponder];
    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",@"test",@"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];
    NSLog(@"%@",[dict description]);
    NSString *updateString = [dict 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:)];    
    [request release];
}

我此时陷入困境,请让我离开这个。
-Thanks提前

I got stuck at this point,Please get me out of this. -Thanks in advance

推荐答案

手动调用OADataFetcher的准备方法。只需在设置请求正文之前设置它。

call prepare method of OADataFetcher manually. Just put it before setting the body of the request.

[request prepare];
[request setHTTPBodyWithString:updateString];

这对我有用。
当您使用Invitation API时,也从OADataFetcher中删除prepare方法。

This is working for me. Also remove the prepare method from the OADataFetcher when you are working with Invitation API.

这篇关于LinkedIn邀请API错误401 [未经授权] -iPhone sdk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆