ios - Upload Image/Video from Photos to Instagram using iPhone Hooks -


i want upload image , video instagram using iphone hooks unable achieve result.

for video, use following code :

alassetslibrary *library = [[alassetslibrary alloc] init];      [library writevideoatpathtosavedphotosalbum:videofilepath completionblock:^(nsurl *asseturl, nserror *error) {     nsstring *cfurl = (nsstring *)cfbridgingrelease(cfurlcreatestringbyaddingpercentescapes(kcfallocatordefault,(cfstringref)[nsstring stringwithformat:@"%@", [asseturl absolutestring]], null, cfstr("!$&'()*+,-./:;=?@_~"), kcfstringencodingutf8));      nsstring *cfcaption = (nsstring *)cfbridgingrelease(cfurlcreatestringbyaddingpercentescapes(kcfallocatordefault,(cfstringref)[nsstring stringwithformat:@"%@", strinstagramcaption], null, cfstr("!$&'()*+,-./:;=?@_~"), kcfstringencodingutf8));      nsstring *instagramstring = [nsstring stringwithformat:@"instagram://library?assetpath=%@&instagramcaption=%@", [asseturl absolutestring], strinstagramcaption];     nslog(@"instagramstring : %@", instagramstring);      nsurl *instagramurl = [nsurl urlwithstring:instagramstring];     nslog(@"instagramurl : %@", instagramurl);      if ([[uiapplication sharedapplication] canopenurl:instagramurl])     {         [[uiapplication sharedapplication] openurl:instagramurl];     }  }]; 

here code share image on instagram using uri.

@property (nonatomic, retain) uidocumentinteractioncontroller *dic;      cgrect rect = cgrectmake(0 ,0 , 0, 0); uigraphicsbeginimagecontextwithoptions(self.view.bounds.size, self.view.opaque, 0.0); [self.view.layer renderincontext:uigraphicsgetcurrentcontext()]; uigraphicsendimagecontext(); nsstring  *jpgpath = [nshomedirectory() stringbyappendingpathcomponent:@"documents/test.igo"];  nsurl *igimagehookfile = [[nsurl alloc] initwithstring:[[nsstring alloc] initwithformat:@"file://%@", jpgpath]]; self.dic.uti = @"com.instagram.photo"; self.dic = [self setupcontrollerwithurl:igimagehookfile usingdelegate:self]; self.dic=[uidocumentinteractioncontroller interactioncontrollerwithurl:igimagehookfile]; [self.dic presentopeninmenufromrect: rect    inview: self.view animated: yes ];   - (uidocumentinteractioncontroller *) setupcontrollerwithurl: (nsurl*) fileurl usingdelegate: (id <uidocumentinteractioncontrollerdelegate>) interactiondelegate {      uidocumentinteractioncontroller *interactioncontroller = [uidocumentinteractioncontroller interactioncontrollerwithurl: fileurl];      interactioncontroller.delegate = interactiondelegate;      return interactioncontroller; } 

also can download sample project here.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -