2013-05-29 7 views
5

Możemy udostępnić wiadomość (tekst) poprzez integrację LinkedIn w aplikacjach na telefon iPhone. Ponadto mogę udostępnić plik image Url w usłudze LinkedIN, ale czy istnieje możliwość udostępnienia adresu URL filmu wideo za pośrednictwem LinkedIn w aplikacjach na telefon iPhone ......?Udostępnianie adresu URL filmu wideo w ramach integracji LinkedIn w telefonie iPhone

z góry dzięki .....

+0

jak udało ci się napisać wiadomość z adresu URL, takich jak: http://www.youtube.com/watch?v=_FaWTNEyG80 pomocy – vensan

Odpowiedz

2

Wykorzystanie MIS-LinkedIn-Share do udostępniania adresu URL.

Wystarczy napisać poniższy kod, aby go udostępnić.

- (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"]; 
} 

Nie zapomnij ustawić interfejsu API i tajnego klucza przed udostępnieniem.

LUB

można również użyć metody z oAuthStarterkit podzielić URL: - kod

Tu pracuje dla oAuthStarterKit

1) Otwórz OAuthLoginView.m plików

2) Znajdź metodę initLinkedInApi, dodaj tutaj swoje klucze API i tajne.

3) Komentarz linie na viewDidAppear w OAuthLoginView jak

- (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]); 
} 
+0

Próbowałem twojego kodu w [MIS-LinkedIn-Share], po pomyślnym ogłoszeniu, że nie jest wyświetlany na LinkedIn, jeśli postUrl jest [http://www.youtube.com/watch?v=_FaWTNEyG80], jakakolwiek pomoc? – vensan

+0

to samo stało się ze mną .. po udanym poście nie przychodzi do aktualizacji – iAnkit

0

Korzystając szkieletu Sharekit jesteśmy w stanie opublikować URL wideo w LinkedIn.for że możemy przekazać adres URL jako string,

SHKItem *shareItem = [SHKItem text:text]; 
    [SHKLinkedIn shareItem:shareItem]; 
+1

Ten sharekit je moją głowę, nie jest poprawnie zainstalowany. – iCoder4777