[Resolved] Facebook & friends request

On the Facebook API page, it says we can post messages and photos to friends accounts, but I have not been able to do it.

All I want is to invite my FB friends to try my Corona-made-app by posting on my FB friends’ wall – preferably by selecting specific friends from a list of FB friends that Corona app may return using Facebook API. (If posting on selected friends’ wall isn’t possible, I’d be happy with posting the invite message to all my FB friends.)

When I do the following, I can post a message on my own FB wall.

-- inside the FB listener  
if event.phase == "login" then  
 local attachment = {  
 name = "MyGameTitle",  
 link = "http://www.mygamesite.com",  
 message = "My message string here",  
 picture = "http://www.mygamesite.com/myimage.png",  
 actions = json.encode( { name="Learn More", link="http://www.mygamesite.com"} )  
 }  
 facebook.request( "me/feed", "POST", attachment )  
end  

But how do I post the attachment on my FB friends’ wall? The following doesn’t seem to do anything:

-- inside the FB listener  
if event.phase == "login" then  
 local attachment = {  
 name = "MyGameTitle",  
 link = "http://www.mygamesite.com",  
 message = "My message string here",  
 picture = "http://www.mygamesite.com/myimage.png",  
 actions = json.encode( { name="Learn More", link="http://www.mygamesite.com"} )  
 }  
 facebook.request( "me/friends" )  
 facebook.request( "friends/feed", "POST", attachment )  
end  

Even though it says on Facebook API page that we should be able to post on friends account, can we really do it right now? If so, is there a code snippet that I can refer to? Facebook sample code that comes with SDK does not include how it may be achieved.

I imagine I need to do something after facebook.request( “me/friends” ), but I don’t know what that might be.

I would so appreciate any help/pointer. (I’m using Daily Build 825 on Mac.)

Naomi [import]uid: 67217 topic_id: 26848 reply_id: 326848[/import]

I’ve been getting heavy into FB api work and first of all highly recommend getting comfy with the open graph explorer they provide

but a quicker answer - you can’t post to friends/feed because it doesn’t know which friend you’re trying to post on the wall for - you want to post to /[friendUserID]/feed for every single friend you want to share with
[import]uid: 32462 topic_id: 26848 reply_id: 108991[/import]

Hey, @jflowers45, thank you for the reply post. I really appreciate it, and it’s really helpful.

Now, does Corona return a list of “friendUser ID” with its Facebook API integration? If it does, I don’t know how to capture it. If it returns a list of friendUserID, we could let the user choose the friendUserID to post the message…

Naomi [import]uid: 67217 topic_id: 26848 reply_id: 108995[/import]

yeah but keep in mind you can’t really test it in the sim - have to be on device or in xcode

when you ask for friends/me it gives you back the list of ids - have a look at the code sample in walter’s teaser from back in the day. most of it is still relevant

http://blog.anscamobile.com/2010/11/api-teaser-graph-requests-in-facebook/ [import]uid: 32462 topic_id: 26848 reply_id: 109006[/import]

specifically this section - see how he loops through the #data - you can call data[i].id as well

elseif ( “request” == event.type ) then
– event.response is a JSON object from the FB server
local response = event.response

– if request succeeds, create a scrolling list of friend names
if ( not event.isError ) then
response = json.decode( event.response )

local friends = {}
local data = response.data
for i=1,#data do
local name = data[i].name [import]uid: 32462 topic_id: 26848 reply_id: 109007[/import]

Wow, thank you @jflowers45. I wasn’t around when Walter’s blog post came out. (Too bad Ansca didn’t include the working sample of it with the SDK.) I so appreciate you posting the link. I’ll work on it tomorrow. I’m done for the day :wink:

Naomi [import]uid: 67217 topic_id: 26848 reply_id: 109008[/import]

no problem. good luck! [import]uid: 32462 topic_id: 26848 reply_id: 109009[/import]

I see event.response from facebook.request( “me/friends” ).

FWIW, event.response looks like the following on console print out:

{“data”:[{“name”:“FirstName1 LastName1”,“id”:“123456”},
{“name”:“FirstName2 LastName2”,“id”:“1234567”},
{“name”:“FirstName200 LastName200”,“id”:“100000000456789”}],
“paging”:{“next”:“https://graph.facebook.com/me/friends?sdk=ios&sdk_version=2&access_token=AAAAAAAAAAAAAAAA&format=json&limit=
5000&offset=5000&__after_id=123456789012345”}}

Note:
* access_token is a super long text string (I replaced it with AAAAAAAAAAAAAAAA)
* after_id is also a long number text string (I replaced it with fake number)

Naomi [import]uid: 67217 topic_id: 26848 reply_id: 109127[/import]

hey can you tell me how to check the user liked my app page or not using corona.

thanks in advance
[import]uid: 186824 topic_id: 26848 reply_id: 136009[/import]

hey can you tell me how to check the user liked my app page or not using corona.

thanks in advance
[import]uid: 186824 topic_id: 26848 reply_id: 136009[/import]