Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Invite friends from Facebook and reward user
Started by isaaczhun Sep 10 2013 12:10 AM

12 replies to this topic
facebook invite friends reward
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

isaaczhun

[GLOBAL: userInfoPane.html]
isaaczhun
  • Starter
  • Pip
  • 6 posts
  • Newbie

Hi,

 

Can someone point me the direction into inviting friends (who is not using the apps) from Facebook and once the friend downloaded the apps, the user is rewarded with some point systems?

 

Thank you. 



[TOPIC: post.html]
#2

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Pro
  • PipPipPipPipPipPip
  • 978 posts
  • Jedi

Hi there,

 

At a high level, the way to do this is:

- Andrew



[TOPIC: post.html]
#3

isaaczhun

[GLOBAL: userInfoPane.html]
isaaczhun
  • Starter
  • Pip
  • 6 posts
  • Newbie

Hi Andrew, 

 

Thanks for pointing me the direction!

 

I'm currently in the midst of getting the response from the request dialog to get the array of facebook id that the user has invited but I am facing some difficulty that I hope you can give me the extra help. 

 

I look at the response data that is been returned from https://developers.facebook.com/docs/reference/dialogs/requests/ documentation and it states that it will return request and to.

 

So what I did is calling the dialog using 

facebook.showDialog("apprequests", { app_id = fbAppID} ) 

 

after which I get the callback in the listener with the following

 


if ( "dialog" == event.type ) then
        inviteText.text = "Friend invited"
        print( "dialog", event.response )
        local data = json.decode(event.response)
        
        for i = 1, #data.to do
            inviteText.text = inviteText.text .. ", " .. data.to[i].user_id
        end
end 

 

to put them in string so that I can cross check the array list. However, it is returning nothing.

 

Did I use the wrong attribute?

 

Thanks in advanced!

 



[TOPIC: post.html]
#4

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Pro
  • PipPipPipPipPipPip
  • 978 posts
  • Jedi

Unfortunately the response from the dialog is not a JSON table, it's an fbconnect URL.  Your statement print("dialog", event.response) should print something like fbconnect://success?to[1]=12345.  Is that what you see?  You then have to parse that string to extract the facebook IDs.

 

- Andrew



[TOPIC: post.html]
#5

isaaczhun

[GLOBAL: userInfoPane.html]
isaaczhun
  • Starter
  • Pip
  • 6 posts
  • Newbie

I just checked the response from the print statement. It is returning nothing. Did I call it wrongly?



[TOPIC: post.html]
#6

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Pro
  • PipPipPipPipPipPip
  • 978 posts
  • Jedi

You should probably put a 'message' field in your parameters to facebook.showDialog.  Without that, it's possible the request may not be sent at all, which would explain why your print is blank.

 

- Andrew



[TOPIC: post.html]
#7

isaaczhun

[GLOBAL: userInfoPane.html]
isaaczhun
  • Starter
  • Pip
  • 6 posts
  • Newbie

Hi Andrew,

 

I tried putting in the message and printing the event out however it is still nil. The code is as follows: 

local function facebookListener( event )
	if ( "session" == event.type ) then
        -- upon successful login, request list of friends of the signed in user
        if ( "login" == event.phase ) then
			inviteText.text = "Pulling friend list..."
			
			local params = {
					app_id = fbAppID,
					message = "Try this! Test 123"
				}
			facebook.showDialog("apprequests", params)
		
            local access_token = event.token
            print( access_token )
        end
    elseif ( "request" == event.type ) then
        -- event.response is a JSON object from the FB server
        local response = event.response

    elseif ( "dialog" == event.type ) then
		print ( "event type:" , event.type)
		print( "event name:" , event.name)
		print ( "event data:", event.data)
		print( "event response: ", event.response)
		
    end
end

 

I am able to pull out the request dialog with my list of friends and invited one of my friends and he indeed received the request as well. However at the print area, I'm getting 

 

I/Corona  (31434): event type:	dialog
I/Corona  (31434): event name:	fbconnect
I/Corona  (31434): event data:	nil
I/Corona  (31434): event response: 

 

Is it because that my friend has already been invited previously which is why it is returning nothing? But there isn't fbconnect://success in the response as well.



[TOPIC: post.html]
#8

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Pro
  • PipPipPipPipPipPip
  • 978 posts
  • Jedi

Try also printing event.didComplete and event.isError and see what they say.

 

It should be fine if you had previously sent an invite to that friend -- you can keep sending requests to the same person without a problem.

 

- Andrew



[TOPIC: post.html]
#9

isaaczhun

[GLOBAL: userInfoPane.html]
isaaczhun
  • Starter
  • Pip
  • 6 posts
  • Newbie

I'm getting

 

I/Corona  (  811): event type:	dialog
I/Corona  (  811): event name:	fbconnect
I/Corona  (  811): event data:	nil
I/Corona  (  811): event response: 	
I/Corona  (  811): event complete:	true
I/Corona  (  811): event error:	false

 

Seems like there is no error. 



[TOPIC: post.html]
#10

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Pro
  • PipPipPipPipPipPip
  • 978 posts
  • Jedi

OK.  Well, I don't see anything that's obviously wrong with your code.  Can you post your build.settings?  It's possible your facebook setup there isn't correct.  Can you also post your code where you call facebook.login()?  I doubt either is the problem, but it doesn't hurt to check.

 

What device are you using?  Are you on an Android or iOS device, and which version?  What version of Corona are you using?

 

- Andrew



[TOPIC: post.html]
#11

isaaczhun

[GLOBAL: userInfoPane.html]
isaaczhun
  • Starter
  • Pip
  • 6 posts
  • Newbie

Hi Andrew,

 

I have got it working which like what you have pointed out, it is the version issue of Corona where I did a search and found you guys talking about build 1154 and previous wasn't working. I had mine at build 1137 and now using build 1202 and it is working like a champ now.

 

Thanks for your help!



[TOPIC: post.html]
#12

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Pro
  • PipPipPipPipPipPip
  • 978 posts
  • Jedi

Yup, that's exactly right.  Glad you got it working.

 

- Andrew



[TOPIC: post.html]
#13

uysuntray

[GLOBAL: userInfoPane.html]
uysuntray
  • Starter
  • PipPip
  • 29 posts
  • Member

@isaaczhun, did the code you past above work perfectly? I also try to use apprequests to invite friends also but after sent to selected friend in list, they got notification after refreshed, but a moment later that notification was removed and seem it show nothing to when we click on notification.




[topic_controls]
[/topic_controls]



Also tagged with one or more of these keywords: facebook, invite friends, reward