Email variables

Get help using Construct 2

Post » Wed May 23, 2012 9:46 pm

Hi everyone. I need some assistance if possible with a facebook app I'm creating.

facebooklogin.php

I can pull up all the variables as you can see, but when I assign it to a variable or array instance as a text and then assign the variable to a textbox it doesn't show up. If you go to

My game site

and click on create it brings you to the page that shows other info. But the email text box is not showing up. I know I'm using tokenat properly as the other items are showing up. Is there a different type of variable to use when storing an email address?
B
68
S
21
G
15
Posts: 701
Reputation: 15,604

Post » Wed May 23, 2012 10:40 pm

Update: haven't checked but I think I found the problem. Safari shows it fine. Not in front of the pc but I'm thinking the size of the text box and how different browsers display the fonts might be to blame and I just need to resize the text box? Is there a way to resize it dynamically at runtime based on length of the string?
B
68
S
21
G
15
Posts: 701
Reputation: 15,604

Post » Thu May 24, 2012 1:27 am

your facebooklogin.php doesn't come his e-mail.

I have no experience about facebook API, i guess it comes a SDK for PHP

there a snippet you may test it:



$loginUrl = $facebook->getLoginUrl(
array(
    'req_perms' => 'email'
)
);

echo '<script>top.location="'.$loginUrl.'";</script>';
die();
B
96
S
25
G
20
Posts: 3,054
Reputation: 22,642

Post » Thu May 24, 2012 1:27 am

or this



<?php

    $facebook = new Facebook(array(
      'appId' => $initMe["appId"],
      'secret' => $initMe["appSecret"],
    ));

    $facebook->setAccessToken($initMe["accessToken"]);
    $user = $facebook->getUser();

    if ($user) {
        $user_profile = $facebook->api('/me');
        print_r($user_profile["email"]);
    }
?>
B
96
S
25
G
20
Posts: 3,054
Reputation: 22,642

Post » Thu May 24, 2012 1:59 am

It does echo back the email as well. I figured it out. Had something to do with the text box layout. It's showing up fine now. Setting the email up was a pain though, had to ask for an extra permission in order to receive it. You were able to see my php file? Any obvious errors? It seems to work fine. Heres a copy of it, I'm new to php so I'll take any help I can get. :)

<?
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('facebook.php');

$config = array(
    'appId' => 'xxxxxx',
    'secret' => 'xxxxxxx',
);

$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>


<?
    if($user_id) {

      // We have a user ID, so probably a logged in user.
      // If not, we'll get an exception, which we handle below.
      try {
        //$info = $facebook->api( '/me/groups', 'GET');
        //$ct = count( $info['data'] );
        //$user_groups = $facebook->api('/me/groups','GET');
        $user_profile = $facebook->api('/me','GET');
        echo $user_profile['name'] . "," . $user_profile['link'] . "," . $user_profile['id'] . "," . $user_profile['first_name'] . "," . $user_profile['last_name'] . "," . $user_profile['username'] . "," . $user_profile['email'] . "," . $user_profile['gender'] . "," . $user_profile['timezone'] . "," . $user_profile['locale'] . "," . $user_profile['verified'] . "," . $user_profile['updated_time'];
       
      } catch(FacebookApiException $e) {
        // If the user is logged out, you can have a
        // user ID even though the access token is invalid.
        // In this case, we'll get an exception, so we'll
        // just ask the user to login again here.
        $login_url = $facebook->getLoginUrl();
        echo 'Please <a href="' . $login_url . '">login.</a>';
        error_log($e->getType());
        error_log($e->getMessage());
      }   
    } else {

      // No user, print a link for the user to login
      $login_url = $facebook->getLoginUrl();
      echo 'Please <a href="' . $login_url . '">login.</a>';

    }

?>
B
68
S
21
G
15
Posts: 701
Reputation: 15,604

Post » Thu May 24, 2012 2:20 am

PHP files can be viewed on server side, NOT client side.

I think you need to ask for extended permissions to display e-mail:

$params = array(
'scope' => 'email, user_activities',
'redirect_uri' => 'https://www.myapp.com/post_login_page'
);

$loginUrl = $facebook->getLoginUrl($params);

http://developers.facebook.com/docs/authentication/permissions/
B
96
S
25
G
20
Posts: 3,054
Reputation: 22,642

Post » Thu May 24, 2012 2:25 am

I did through the app center. If you follow the link to my game you'll see email listed as a permission and my create screen now shows the email address properly. Thanks for the quick replies though @Joannesalfa.
B
68
S
21
G
15
Posts: 701
Reputation: 15,604


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], WhosWho and 14 guests