我想从我的 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 设备没有收到任何响应。