在iPhone的LinkedIn集成中共享视频URL

在iPhone的LinkedIn集成中共享视频URL,iphone,ios,video,linkedin,Iphone,Ios,Video,Linkedin,我们可以通过iPhone应用程序中的LinkedIn集成来共享消息(文本)。此外,我可以在LinkedIN中共享一个视频url,但是否有可能在iPhone应用程序中通过LinkedIN共享视频url 提前感谢….通过使用Sharekit框架,我们可以在LinkedIn中发布视频URL。为此,我们可以将URL作为字符串传递 SHKItem *shareItem = [SHKItem text:text]; [SHKLinkedIn shareItem:shareItem]; 用于共享url

我们可以通过iPhone应用程序中的LinkedIn集成来共享消息(文本)。此外,我可以在LinkedIN中共享一个视频url,但是否有可能在iPhone应用程序中通过LinkedIN共享视频url


提前感谢….

通过使用Sharekit框架,我们可以在LinkedIn中发布视频URL。为此,我们可以将URL作为字符串传递

SHKItem *shareItem = [SHKItem text:text];
  [SHKLinkedIn shareItem:shareItem];
用于共享url

只需编写以下代码来共享

- (IBAction)share:(id)sender {
[[MISLinkedinShare sharedInstance] shareContent:self postTitle:@"Title" postDescription:@"Description" postURL:@"http://www.youtube.com/watch?v=_FaWTNEyG80" postImageURL:@"http://www.google.com/images/errors/logo_sm.gif"];
}
共享前不要忘记设置api和密钥

您还可以使用方法来共享url:-

下面是oAuthStarterKit的工作代码

1)打开文件OAuthLoginView.m

2)找到initLinkedInApi方法,在此处添加api和密钥。

3)视图上的注释行在OAuthLoginView中显示为

- (void)viewDidAppear:(BOOL)animated
{
    if ([apikey length] < 64 || [secretkey length] < 64)
    {
//        UIAlertView *alert = [[UIAlertView alloc]
//                          initWithTitle: @"OAuth Starter Kit"
//                          message: @"You must add your apikey and secretkey.  See the project file readme.txt"
//                          delegate: nil
//                          cancelButtonTitle:@"OK"
//                          otherButtonTitles:nil];
//        [alert show];
//        [alert release];
//        
//        // Notify parent and close this view
//        [[NSNotificationCenter defaultCenter] 
//         postNotificationName:@"loginViewDidFinish"        
//         object:self
//         userInfo:self.profile];

//        [self dismissModalViewControllerAnimated:YES];
    }

    [self requestTokenFromProvider];
}

- (void)shareImp
{
    NSLog(@"share Imp called ");
    NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~/shares"];
    OAMutableURLRequest *request =[[OAMutableURLRequest alloc] initWithURL:url
                                    consumer:consumer
                                       token:self.accessToken
                                    callback:nil
                           signatureProvider:nil];

    NSMutableDictionary *contents=[[NSMutableDictionary alloc] init];
    [contents setValue:@"description goes here" forKey:@"description"];
    [contents setValue:@"www.google.com" forKey:@"submitted-url"];
    [contents setValue:@"title goes here" forKey:@"title"];
    [contents setValue:@"http://economy.blog.ocregister.com/files/2009/01/linkedin-logo.jpg" forKey:@"submitted-image-url"];

    NSMutableDictionary *visible=[[NSMutableDictionary alloc] init];
    [visible setValue:@"anyone" forKey:@"code"];

    NSMutableDictionary *updatedic=[[NSMutableDictionary alloc] init];

    [updatedic setObject:visible forKey:@"visibility"];
    [updatedic setObject:contents forKey:@"content"];
    [updatedic setValue:@"Check out the LinkedIn Share API!" forKey:@"comment"];

    NSMutableData *data = [[NSMutableData alloc] init];
    NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];
    [archiver encodeObject:updatedic forKey:@"share"];
    [archiver finishEncoding];
    [archiver release];

    NSLog(@"post dictionary is %@",updatedic);


    NSData *postData=[NSData dataWithData:data];
    [request setValue:@"json" forHTTPHeaderField:@"x-li-format"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setValue:[NSString stringWithFormat:@"%d",[postData length]] forHTTPHeaderField:@"Content-Length"];

    [request setHTTPBody:postData];
    [request setHTTPMethod:@"POST"];

    OADataFetcher *fetcher = [[OADataFetcher alloc] init];
    [fetcher fetchDataWithRequest:request
                         delegate:self
                didFinishSelector:@selector(postUpdateApiCallResult:didFinish:)
                  didFailSelector:@selector(postUpdateApiCallResult:didFail:)];

    [request release];
}

- (void)postUpdateApiCallResult:(OAServiceTicket *)ticket didFinish:(NSData *)data
{
    NSLog(@"did finish called ");

    NSString *responseBody = [[NSString alloc] initWithData:data
                                                   encoding:NSUTF8StringEncoding];

    NSLog(@"response body after posting is %@",responseBody);

    [responseBody release];
    [self dismissModalViewControllerAnimated:YES];
}

- (void)postUpdateApiCallResult:(OAServiceTicket *)ticket didFail:(NSData *)error
{
    NSLog(@"%@",[error description]);
}
-(void)视图显示:(BOOL)动画
{
if([apikey length]<64 | |[secretkey length]<64)
{
//UIAlertView*警报=[[UIAlertView alloc]
//initWithTitle:@“OAuth初学者工具包”
//消息:@“您必须添加apikey和secretkey。请参阅项目文件readme.txt”
//代表:无
//取消按钮:@“确定”
//其他按钮:无];
//[警报显示];
//[警报发布];
//        
////通知父级并关闭此视图
//[[NSNotificationCenter defaultCenter]
//postNotificationName:@“LoginViewdFinish”
//对象:self
//userInfo:self.profile];
//[自我解散Modalviewcontrolleranimated:是];
}
[self-requestTokenFromProvider];
}
-(无效)shareImp
{
NSLog(@“称为共享Imp”);
NSURL*url=[NSURL URLWithString:@”http://api.linkedin.com/v1/people/~/股“];
OAMutableURLRequest*请求=[[OAMutableURLRequest alloc]initWithURL:url
消费者:消费者
令牌:self.accessToken
回拨:无
签名提供者:无];
NSMutableDictionary*contents=[[NSMutableDictionary alloc]init];
[contents setValue:@“description在这里”forKey:@“description”];
[contents setValue:@“www.google.com”forKey:@“提交的url”];
[contents setValue:@“title在这里”forKey:@“title”];
[内容设置值:@”http://economy.blog.ocregister.com/files/2009/01/linkedin-logo.jpg“forKey:@“提交的图像url”];
NSMutableDictionary*可见=[[NSMutableDictionary alloc]init];
[可见设置值:@“任何人”forKey:@“代码”];
NSMutableDictionary*updatedic=[[NSMutableDictionary alloc]init];
[updatedic setObject:visible forKey:@“可见性”];
[updatedic setObject:contents-forKey:@“content”];
[updatedic setValue:@“查看LinkedIn共享API!”forKey:@“评论”];
NSMutableData*数据=[[NSMutableData alloc]init];
NSKeyedArchiver*archiver=[[NSKeyedArchiver alloc]initForWritingWithMutableData:data];
[archiver encodeObject:updatedic forKey:@“共享”];
[archiver finishEncoding];
[档案发布];
NSLog(@“post dictionary is%@”,updatedic);
NSData*postData=[NSData dataWithData:data];
[请求设置值:@“json”用于HttpHeaderField:@“x-li-format”];
[请求设置值:@“应用程序/json”用于HttpHeaderField:@“内容类型”];
[request setValue:[NSString stringWithFormat:@“%d”,[postData length]]forHTTPHeaderField:@“内容长度”];
[请求setHTTPBody:postData];
[请求设置HttpMethod:@“POST”];
OADataFetcher*fetcher=[[OADataFetcher alloc]init];
[fetcher fetchDataWithRequest:请求
代表:赛尔夫
didFinishSelector:@selector(postUpdateApiCallResult:didFinish:)
didFailSelector:@selector(postUpdateApiCallResult:didFail:)];
[请求释放];
}
-(void)postUpdateApiCallResult:(OAServiceTicket*)票证完成:(NSData*)数据
{
NSLog(@“完成调用”);
NSString*ResponseBy=[[NSString alloc]initWithData:data
编码:NSUTF8StringEncoding];
NSLog(@“发布后的响应正文为%@”,响应正文);
[应答器发布];
[自我解散Modalviewcontrolleranimated:是];
}
-(void)postUpdateApiCallResult:(OAServiceTicket*)票证失败:(NSData*)错误
{
NSLog(@“%@,[错误描述]);
}

这个共享套件让我头疼,安装不正确。我在[MIS LinkedIn Share]上尝试了你的代码,成功发布后,如果PostRL是[,它就不会显示在LinkedIn上,有什么帮助吗?我也有同样的情况。成功发布后,它不会出现更新。你如何成功发布了一条Url为:any help的消息