ios - Instagram InstagramCaption 不工作

标签 ios objective-c hook instagram instagram-api

我有以下用于在 Instagram 上分享文章的代码。

-(void) shareInstagram {
    NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
    if([[UIApplication sharedApplication] canOpenURL:instagramURL]) //check for App is install or not
    {
        UIImage *instaImage = mImg.image;
        NSData *imageData = UIImagePNGRepresentation(instaImage); //convert image into .png format.
        NSLog(@"imageData.leeee===%d", imageData.length);
        if (imageData.length<=100) {
            [self.view makeToast:localize(@"instaErr2") duration:2.0 position:@"bottom"];
        } else {
            NSFileManager *fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
            NSString *documentsDirectory = [paths objectAtIndex:0]; //create NSString object, that holds our exact path to the documents directory
            NSString *fullPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"insta.igo"]]; //add our image to the path
            [fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; //finally save the path (image)
            NSLog(@"image saved");

            CGRect rect = CGRectMake(0 ,0 , 0, 0);
            UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0);
            [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
            UIGraphicsEndImageContext();
            NSString *fileNameToSave = [NSString stringWithFormat:@"Documents/insta.igo"];
            NSString  *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:fileNameToSave];
            NSLog(@"jpg path %@",jpgPath);
            NSString *newJpgPath = [NSString stringWithFormat:@"file://%@",jpgPath];
            NSLog(@"with File path %@",newJpgPath);
            NSURL *igImageHookFile = [[NSURL alloc]initFileURLWithPath:newJpgPath];
            NSLog(@"url Path %@",igImageHookFile);

            self.documentController.UTI = @"com.instagram.exclusivegram";
            self.documentController = [self setupControllerWithURL:igImageHookFile usingDelegate:self];
            self.documentController=[UIDocumentInteractionController interactionControllerWithURL:igImageHookFile];

            NSString *globalString;

            if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"PoPinFrom"] isEqualToString:@"user"]) {
                globalString = [NSString stringWithFormat:@"%@ @ %@\n\nhttp://egkw.com/ArticleDetail.aspx?id=%@\n\niPhone : %@\n\nAndroid : %@", [[productDetailsArray objectAtIndex:0] valueForKey:@"Title"], localize(@"appName"), [[productDetailsArray objectAtIndex:0] valueForKey:@"Id"], localize(@"appStoreLink"), localize(@"playStoreLink")];
            } else {
                globalString = [NSString stringWithFormat:@"%@ @ %@\n\nhttp://egkw.com/ArticleDetail.aspx?id=%@\n\niPhone : %@\n\nAndroid : %@", [[productDetailsArray objectAtIndex:0] valueForKey:@"Title"], localize(@"appName"), [[productDetailsArray objectAtIndex:0] valueForKey:@"Id"], localize(@"appStoreLink"), localize(@"playStoreLink")];
            }

            globalString = [NSString stringWithFormat:@"%@\n\n#EGKW", globalString];
            NSLog(@"insta==globalString==%@", globalString);
            self.documentController.annotation=[NSDictionary dictionaryWithObjectsAndKeys:globalString, @"InstagramCaption", nil];
            // self.documentController.annotation = [NSDictionary dictionaryWithObject:globalString forKey:@"InstagramCaption"];
            [self.documentController presentOpenInMenuFromRect:rect inView: self.view animated:YES];
        }
    }
    else
    {
        NSLog (@"Instagram not found");
        DTAlertView *myAl = [DTAlertView alertViewWithTitle:localize(@"err001") message:localize(@"instaErr") delegate:nil cancelButtonTitle:localize(@"dismiss") positiveButtonTitle:nil];
        [myAl setDismissAnimationWhenButtonClicked:DTAlertViewAnimationSlideTop];
        [myAl showWithAnimation:DTAlertViewAnimationSlideBottom];
    }
}

此代码之前运行良好。然而,当我注意到时,我发现 Instagram 中没有显示标题。经过研究我改变了

 self.documentController.annotation=[NSDictionary dictionaryWithObjectsAndKeys:globalString, @"InstagramCaption", nil];

self.documentController.annotation = [NSDictionary dictionaryWithObject:globalString forKey:@"InstagramCaption"];

但还是不行。

知道出了什么问题吗?

Instagram 是否像 Facebook 一样更改了任何政策?

最佳答案

Instagram 现在已经删除了使用交互 Controller 填充标题字段。

查看他们的这篇博文

Instagram developer blog

关于ios - Instagram InstagramCaption 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31915122/

相关文章:

ios - 如何在 VLC 播放器上播放原始 YUV NV12 文件

ios - NSXMLParser parse() 只工作一次

ios - 如何从时间限制的 IOS SDK 中的 Gmail 收件箱中获取电子邮件?

ios - 如何从我的应用程序关闭 Safari

objective-c - 适用于 NSArray 中包含的字符串数量

c++ - 在 Winx64 上使用 User32InitializeImmEntryTable?

c# - C#鼠标钩

c++ - 如何使用 SendInput 重复击键?

iphone - App Store 批准需要身份验证的应用程序

ios - 在 ReactiveCocoa 中订阅信号进行网络调用的正确替代方法是什么?