Tagging Facebook photos using Facebook.request - anybody done this?

Hi Everybody,

I’m hoping to tag a photo on Facebook from within my app programmatically, using Facebook.request - I’m able to gather the photo’s ID (from what I can tell, we cannot tag photos until AFTER we’ve uploaded them), I’m able to gather the FB user IDs for the people I want to tag. I should be able to do this, but I’m having a hard time getting the syntax just right.

I’m pretty sure that the call should look something like this (this is obviously just a snippet, not fully-functioning):

local photoID = 0 --PHOTO'S FACEBOOK ID# local friendID = 0 --FRIEND'S FACEBOOD ID# facebook.request( photoID.."/tags", "POST", {{tag\_uid = friendID}})

Keep in mind that the above code does not work, but it should be close to correct, based on the Graph API documentation found here: https://developers.facebook.com/docs/graph-api/reference/photo/tags/

Has anybody successfully tagged photos from within their Corona app? Would you mind sharing if you have? Anybody out there better at translating Graph API documentation into Corona/Lua code than I am? Would love to hear from some of you.

Thanks!

-Jason Schroeder

Only thing that comes to mind is that you possibly have extra curly brackets around _ {tag_uid = friendID}  _? 

Sorry for the late reply, but thanks Jon! Turns out you were right - and partly to blame was me trying to tag more than one person in a single API call (hence the extra curly brackets - I wanted to have a table that contained a sub-table for each person to tag).

I managed to get this working, including tagging multiple users by removing those extra brackets and running a simple for loop like this:

local photoID = 0 -- PHOTO'S FB ID# local tagTable = {x, y, z} -- WHERE X, Y, AND Z ARE FRIEND'S FACEBOOK ID#s for i=1,#tagTable do facebook.request(photoID.."/tags", "POST", {tag\_uid = tagTable[i]}) end 

Such a simple fix, but I’m grateful for the extra set of eyes…I do all my coding in the wee hours (can’t quit the day job yet), so oftentimes my brain misses these simple little things on account of the sleep depravation. :slight_smile:

Thanks again!

So is it possible to upload and tag at the same time?

Hi TartarSauce:

No, not in my experience. However, you can post the photo, which then returns it’s FB ID, then post your tags one at a time to that returned FB ID. It adds a few extra lines of code, but it’s not too difficult, and works well.

Only thing that comes to mind is that you possibly have extra curly brackets around _ {tag_uid = friendID}  _? 

Sorry for the late reply, but thanks Jon! Turns out you were right - and partly to blame was me trying to tag more than one person in a single API call (hence the extra curly brackets - I wanted to have a table that contained a sub-table for each person to tag).

I managed to get this working, including tagging multiple users by removing those extra brackets and running a simple for loop like this:

local photoID = 0 -- PHOTO'S FB ID# local tagTable = {x, y, z} -- WHERE X, Y, AND Z ARE FRIEND'S FACEBOOK ID#s for i=1,#tagTable do facebook.request(photoID.."/tags", "POST", {tag\_uid = tagTable[i]}) end 

Such a simple fix, but I’m grateful for the extra set of eyes…I do all my coding in the wee hours (can’t quit the day job yet), so oftentimes my brain misses these simple little things on account of the sleep depravation. :slight_smile:

Thanks again!

So is it possible to upload and tag at the same time?

Hi TartarSauce:

No, not in my experience. However, you can post the photo, which then returns it’s FB ID, then post your tags one at a time to that returned FB ID. It adds a few extra lines of code, but it’s not too difficult, and works well.