C2 Facebook plugin + email

Post your completed addons to share with the community

Post » Wed Jan 22, 2014 2:42 pm

Hello guys,
I know how to use the Facebook plugin very well. I used it in one of our games and it worked perfect. Facebook login, ranking, etc.

The thing is that I need the same basic functionalities plus facebook user email. No more else, that's why I don't want to try the advanced Facebook third party plugins. The one that comes with C2 works pretty well.

Does anybody know how to do this?

I've read that user email needs special permissions, so I think it's not that simple as adding the var email in the plugin code and I don't have experience creating or modifying plugins.

Thank you in advance :)
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,613

Post » Thu Jan 23, 2014 5:20 pm

Ok, i'll give you few hints where to start, and hopefully you'll finish this edit on your own.


Open up folder where facebook plugin is, and open runtime.js in notepad++. First we'll have to ask user for a permission to access email. Scroll to the line 232 and add this line of code:

          if (fbCanPublishStream) {
               perms.push("publish_stream");
                         // ask for email access
               perms.push("email");
               }

You'll have to request 'publish to stream' in C2 to get access for email in this case.


Then we'll throw the email to the log somwhere on the line 55 where you'll see this:

function onFBLogin()
     {
          if (!fbLoggedIn)
          {
               fbLoggedIn = true;
               fbRuntime.trigger(cr.plugins_.Facebook.prototype.cnds.OnLogIn, fbInst);
               
               FB.api('/me', function(response) {
                                   fbFullName = response["name"];
                                   fbFirstName = response["first_name"];
                                   fbLastName = response["last_name"];

/// we'll access email here, if you want to have it as expression inside construct do it same as for first_name, or last_name. Don't forget to add an expression in edittime.js
                                   console.log(response["email"]);
                                   fbRuntime.trigger(cr.plugins_.Facebook.prototype.cnds.OnNameAvailable, fbInst);
                              });
          }
     };



That's about it. you have access to email. As for getting email as an expression inside C2, i left that for your enjoyment in exploring the beautiful C2 sdk. :)

Be nice until it's time to not be nice
B
36
S
10
G
9
Posts: 293
Reputation: 6,712

Post » Thu Jan 23, 2014 5:59 pm

@JohnnySheffield so nice of you! That's more than enough :D :D :D I will try it and tell you the results. Hope it works. Thank you very much... very very clear.
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,613

Post » Wed Apr 16, 2014 9:52 am

@johnnysheffield really great :)
B
7
S
1
Posts: 20
Reputation: 776


Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 4 guests