如何打开Pinterest和Linked iOS应用程序分享一些东西?

时间:2015-08-22 05:54:58

标签: ios post share linkedin pinterest

我编写了一个iOS应用程序,它需要打开Pinterest和LinkedIn来分享一些东西。 (如果用户没有安装它,它将是开放的safari并分享 - 发布一些东西)。

我尝试使用一些方案,但它没有用。也许反正这样做。

我找到了一些与Pinterest应用程序共享的URL方案。它对我有用:

NSString *sharingURL = [[NSString stringWithFormat:@"pinterestsdk.v1://pinit/?client_id=%@&source_url=%@&image_url=%@&app_name=%@&suggested_board_name=%@&description=%@",@"xxxxxxx", @"shareurl.com", @"shareurl.com/shareMedia.png", @"Your_App_Name", @"Board_Name", @"Your_Description"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:sharingURL]])
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:sharingURL]];
}

使用LinkedIn,我正在研究最佳解决方案。

哦,也许有机会与LinkedIn应用分享,当你在Safari浏览上按分享时,它有一个LinkedIn的选项,它没有登录(safari之前没有登录LinkedIn,只是LinkedIn应用程序。)。但LinkedIn的SDK只支持REST API。

谢谢,抱歉我的英语不好。

1 个答案:

答案 0 :(得分:2)

  

打开Pinterest用户个人资料

- (IBAction)openPinterestUser:(id)sender {

    // open the Pinterest App if available
    if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"pinterest://user/juliav1"]]) {

        // opening the app didn't work - let's open Safari
        if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.pinterest.com/versluis2000/"]]) {

            // nothing works - perhaps we're not online
            NSLog(@"Dang!");
        }
    }
}
  

开设Pinterest董事会

- (IBAction)openPinterestBoard:(id)sender {

    // open the Pinterest App if available
    if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"pinterest://board/versluis2000/ios-projects"]]) {

        // opening the app didn't work - let's open Safari
        if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.pinterest.com/versluis2000/ios-projects/"]]) {

            // nothing works - perhaps we're not online
            NSLog(@"Dang!");
        }
    }
}
  

打开Pinterest Pin

- (IBAction)openPinterestPin:(id)sender {

    // open the Pinterest App if available
    if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"pinterest://pin/76279787413881109"]]) {

        // opening the app didn't work - let's open Safari
        if (![[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.pinterest.com/pin/76279787413881109/"]]) {

            // nothing works - perhaps we're not online
            NSLog(@"Dang!");
        }
    }
}

使用Pintrest SDK

  

Pin方法

- (void)getPinWithIdentifier:(NSString *)pinId
                      fields:(NSSet *)fields
                 withSuccess:(PDKClientSuccess)successBlock
                  andFailure:(PDKClientFailure)failureBlock;

- (void)createPinWithImageURL:(NSURL *)imageURL
                         link:(NSURL *)link
                      onBoard:(NSString *)boardId
                  description:(NSString *)pinDescription
                  withSuccess:(PDKClientSuccess)successBlock
                   andFailure:(PDKClientFailure)failureBlock;

- (void)createPinWithImage:(UIImage *)image
                      link:(NSURL *)link
                   onBoard:(NSString *)boardId
               description:(NSString *)pinDescription
                  progress:(PDKPinUploadProgress)progressBlock
               withSuccess:(PDKClientSuccess)successBlock
                andFailure:(PDKClientFailure)failureBlock;

以下是Pintrest IOS SDK链接pinterest/ios-pdk

  

1https://github.com/pinterest/ios-pdk

iOS版PinterestSDK允许您使用Pinterest对帐户进行身份验证,并代表经过身份验证的用户发出请求。有关支持的端点的详细信息,visit the Pinterest API