A Fuse Powered Company

Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tagging Facebook photos using Facebook.request - anybody done this?
Started by schroederapps Apr 22 2014 10:26 PM

4 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Pro
  • PipPipPipPipPipPip
  • 177 posts
  • Jedi

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



[TOPIC: post.html]
#2

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Pro
  • PipPipPipPipPipPip
  • 992 posts
  • Jedi

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



[TOPIC: post.html]
#3

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Pro
  • PipPipPipPipPipPip
  • 177 posts
  • Jedi

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. :)

 

Thanks again!



[TOPIC: post.html]
#4

tartarsaucemedia

[GLOBAL: userInfoPane.html]
tartarsaucemedia
  • Starter
  • PipPip
  • 18 posts
  • Member

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

[TOPIC: post.html]
#5

schroederapps

[GLOBAL: userInfoPane.html]
schroederapps
  • Pro
  • PipPipPipPipPipPip
  • 177 posts
  • Jedi

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.


[topic_controls]
[/topic_controls]