Share on instagram functionality possible?

Hi all,

I’m wondering if anybody has attempted to do instagram integration in any of their corona apps? I have a photo decorating app and I’m wondering how I would go about doing a share on instagram button… could anyone help me out?

I saw this thread here about the document interaction API (which Corona does not have), but are there any other ideas?

Thanks in advance!

The instagram API does not allow you to post photos to their service, has nothing to do with Corona or the link you posted it has to do with Instagram not allowing that feature.

Yes I know the instagram API does not allow you to post photos. The only way I know of is to use Document Interaction to open the instagram app also installed on the device with a photo pushed from my app to it (which is described in the link I referenced.) Corona does not support Document Interaction and thus am asking if there is any other way?

The instagram API does not allow you to post photos to their service, has nothing to do with Corona or the link you posted it has to do with Instagram not allowing that feature.

Yes I know the instagram API does not allow you to post photos. The only way I know of is to use Document Interaction to open the instagram app also installed on the device with a photo pushed from my app to it (which is described in the link I referenced.) Corona does not support Document Interaction and thus am asking if there is any other way?

I did it.

You have to save your picture to the document directory, then use this kind of code:

 function share\_on\_instagram(pFileName) local path = string.urlEncode(system.pathForFile( pFileName, system.DocumentsDirectory )) local url = "instagram://library?AssetPath="..path if system.openURL( url ) then -- OK ! else native.showAlert( "Instagram not available", "Instagram is not available on this device. You should install it first.", {"OK"} ) end end

I searched for hours and found this undocumented way. Enjoy!

Awesome I will try this right now!

@david-pro

Did you try this on iphone or android? I can’t seem to get it to work on android. It brings up a popup saying that I need to reset my password, and then another one saying that it can’t open the url.

Any ideas?

Also, I don’t seem to have string.urlEncode so I am using this:

local socketUrl = require("socket.url") socketUrl.escape()

Last thing: what are you saving your filename as? I am saving mine as a jpg in system.DocumentsDirectory.

If it helps: here is my encoded url:

instagram://library?AssetPath=%2fdata%2fdata%2fcom%2espacewolf%2eapps%2esnapbook%2efree%2fapp_data%2fimage%2dcreatedate%2d1423087518%2ejpg

I also tried this url:

instagram://library?AssetPath=%2Fdata%2Fdata%2Fcom.spacewolf.apps.snapbook.free%2Fapp_data%2Fimage-createdate-1423096895.jpg

This is what I see in the logcat:

I/ActivityManager(  379): START u0 {act=android.intent.action.VIEW dat=instagram

://library?AssetPath=/data/data/com.spacewolf.apps.snapbook.free/app_data/image-

createdate-1423096895.jpg cmp=com.instagram.android/.login.PasswordResetActivity

} from pid 18498

In the app I still get the same OS popup saying I need to reset my password and another one saying it cannot open that URL.

I don’t know why cmp is being set to com.instagram.android/.login.PasswordResetActivity. I suspect this is the problem?

It’s iOS sorry I did not mention.

By the way, it’s not the miracle I was expected, it cannot found the picture, it opens the library but nothing more. To work perfectly Corona should return us the real path of the asset library when we save a picture to the camera roll, but it do not.

The discussion continue here:

http://forums.coronalabs.com/topic/54267-here-is-how-to-share-a-picture-image-with-instagram-with-corona-sdk-without-enterprise/

I did it.

You have to save your picture to the document directory, then use this kind of code:

 function share\_on\_instagram(pFileName) local path = string.urlEncode(system.pathForFile( pFileName, system.DocumentsDirectory )) local url = "instagram://library?AssetPath="..path if system.openURL( url ) then -- OK ! else native.showAlert( "Instagram not available", "Instagram is not available on this device. You should install it first.", {"OK"} ) end end

I searched for hours and found this undocumented way. Enjoy!

Awesome I will try this right now!

@david-pro

Did you try this on iphone or android? I can’t seem to get it to work on android. It brings up a popup saying that I need to reset my password, and then another one saying that it can’t open the url.

Any ideas?

Also, I don’t seem to have string.urlEncode so I am using this:

local socketUrl = require("socket.url") socketUrl.escape()

Last thing: what are you saving your filename as? I am saving mine as a jpg in system.DocumentsDirectory.

If it helps: here is my encoded url:

instagram://library?AssetPath=%2fdata%2fdata%2fcom%2espacewolf%2eapps%2esnapbook%2efree%2fapp_data%2fimage%2dcreatedate%2d1423087518%2ejpg

I also tried this url:

instagram://library?AssetPath=%2Fdata%2Fdata%2Fcom.spacewolf.apps.snapbook.free%2Fapp_data%2Fimage-createdate-1423096895.jpg

This is what I see in the logcat:

I/ActivityManager(  379): START u0 {act=android.intent.action.VIEW dat=instagram

://library?AssetPath=/data/data/com.spacewolf.apps.snapbook.free/app_data/image-

createdate-1423096895.jpg cmp=com.instagram.android/.login.PasswordResetActivity

} from pid 18498

In the app I still get the same OS popup saying I need to reset my password and another one saying it cannot open that URL.

I don’t know why cmp is being set to com.instagram.android/.login.PasswordResetActivity. I suspect this is the problem?

It’s iOS sorry I did not mention.

By the way, it’s not the miracle I was expected, it cannot found the picture, it opens the library but nothing more. To work perfectly Corona should return us the real path of the asset library when we save a picture to the camera roll, but it do not.

The discussion continue here:

http://forums.coronalabs.com/topic/54267-here-is-how-to-share-a-picture-image-with-instagram-with-corona-sdk-without-enterprise/