将Pinterest与我的iOS应用程序集成

时间:2012-10-09 07:07:39

标签: ios pinterest url-scheme

我想从我的iPhone应用程序将图像发布到pinterest帐户,没有任何来自pinterest的API版本,这就是为什么我尝试将其与URL Scheme集成但未获得成功。这是代码,

- (void)pinThroughURLScheme {
    NSString *urlString = PinterestURLMake(self.image, nil, @"alt", @"image.jpeg", NO);
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}

NSString *PinterestURLMake(UIImage *image, NSString *urlString, NSString *alt, NSString    *title, BOOL isVideo) {
    NSString *base64ImageString = [NSString stringWithFormat:@"data:image/png;base64,%@",    NSStringFromUIImage(image)];
    NSString *encodedBase64ImageString = [base64ImageString urlEncodeUsingEncoding:NSUTF8StringEncoding];
    NSString *encodedURLValue = [urlString urlEncodeUsingEncoding:NSUTF8StringEncoding];
    NSString *encodedAltValue = [alt urlEncodeUsingEncoding:NSUTF8StringEncoding];
    NSString *encodedTitleValue = [[NSString stringWithFormat:@"%@ %.0fx%.0f pixels", title, image.size.width, image.size.height] urlEncodeUsingEncoding:NSUTF8StringEncoding];
    NSString *videoValue = isVideo ? @"true" : @"false";    
    return [NSString stringWithFormat:@"pinterest://pin/create/bookmarklet/?url=URL-OF-THE-PAGE-TO-PIN&media=URL-OF-THE-IMAGE-TO-PIN&description=ENTER-YOUR-DESCRIPTION-FOR-THE-PIN",
        encodedBase64ImageString,
        urlString ? [NSString stringWithFormat:@"&url=%@", encodedURLValue] : @"",
        alt ? [NSString stringWithFormat:@"&alt=%@", encodedAltValue] : @"",
        title ? [NSString stringWithFormat:@"&title=%@", encodedTitleValue] : @"",
        videoValue];
}  

运行此代码后,我的iPhone设备没有得到任何回复。

2 个答案:

答案 0 :(得分:3)

好了,因为你知道基础知识,也许你可以查看以下链接,希望它可以帮助你:)

iOS application integration with pinterest

答案 1 :(得分:2)

截至2013年5月20日,Pinterest发布了用于固定内容的iOS SDK。

查看their Developers site了解详情。