Author Topic: Etano facebook connect  (Read 14930 times)

sarthakinfotech

  • Confirmed Member
  • **
  • Posts: 4
  • Karma: +0/-0
Re: Etano facebook connect
« Reply #15 on: February 16, 2015, 11:09:48 AM »
Hi
Its under progress.


Good day.

sante

  • Active Member
  • ***
  • Posts: 26
  • Karma: +0/-0
Re: Etano facebook connect
« Reply #16 on: April 28, 2015, 03:59:05 PM »
Did anything happen with this Sarthak?

JohnHarperJr

  • Active Member
  • ***
  • Posts: 78
  • Karma: +6/-0
    • SocialGratis.com
Re: Etano facebook connect
« Reply #17 on: May 06, 2015, 03:14:00 PM »
If anyone is interested, I got this to work on a shared buisness Hostgator account:

1) create an app on facebook
2) make note of your app id and your app secret id
3) Download the facebook sdk for PHP https://developers.facebook.com/docs/reference/php/4.0.0, upload it to your server

4) In the fb.config file located at the top level of your sdk, replace the code with

Code: [Select]
<?php
session_start
();
require_once 
'autoload.php';


use 
Facebook\FacebookSession;
use 
Facebook\FacebookRedirectLoginHelper;
use 
Facebook\FacebookRequest;
use 
Facebook\FacebookResponse;
use 
Facebook\FacebookSDKException;
use 
Facebook\FacebookRequestException;
use 
Facebook\FacebookAuthorizationException;
use 
Facebook\GraphObject;
use 
Facebook\Entities\AccessToken;
use 
Facebook\HttpClients\FacebookCurlHttpClient;
use 
Facebook\HttpClients\FacebookHttpable;

// start session
session_start();

// init app with app id and secret
FacebookSession::setDefaultApplication'YOURAPPID','YOURSECRETID' );


$helper = new FacebookRedirectLoginHelper('http://MYSITE/PATHTOFBCONFIG.PHP' );


// see if a existing session exists
if ( isset( $_SESSION ) && isset( $_SESSION['fb_token'] ) ) {
  
// create new session from saved access_token
  
$session = new FacebookSession$_SESSION['fb_token'] );

  
// validate the access_token to make sure it's still valid
  
try {
    if ( !
$session->validate() ) {
      
$session null;
    }
  } catch ( 
Exception $e ) {
    
// catch any exceptions
    
$session null;
  }

} else {
  
// what to do if no session exists

  
try {
    
$session $helper->getSessionFromRedirect();
  } catch( 
FacebookRequestException $ex ) {
    
// When Facebook returns an error what do you do?
  
} catch( Exception $ex ) {
    
// When validation fails or other local issues what do you do?
    
echo $ex->message;
  }

}

// see if we have a session
if ( isset( $session ) ) {

  
// save the session
  
$_SESSION['fb_token'] = $session->getToken();
  
// create a session using saved token or the new one we generated at login
  
$session = new FacebookSession$session->getToken() );

  
// graph api request for user data
  
$request = new FacebookRequest$session'GET''/me' );
  
$response $request->execute();
  
// get response
  
$graphObject $response->getGraphObject()->asArray();

  
// print profile data
  
echo '<pre>' print_r$graphObject) . '</pre>';

  
// print logout url using session and redirect_uri (logout.php page should destroy the session)
  
echo '<a href="' $helper->getLogoutUrl$session'http://yourwebsite.com/app/logout.php' ) . '">Logout</a>';
  
  
//The above is outputted after a successful login. If you are successful it should show an array of the facebook info along with the logout link you provided. You can pretty much do whatever you want with that array of information. 

} else {
  
// show login url
  
echo '<a href="' $helper->getLoginUrl( array( 'email''user_friends' ) ) . '">Login</a>';
//the array above in the login is where you ask for extra permissions to get things such as the email and user's friends, facebook requires approval for certain permissions
}
?>


5) Make sure you replace the items in bold with your own variables


6) Return to your application at developers.facebook.com/apps/ and add the link to your fb.config file to the oauth urls under
settings -> advanced => security

JohnHarperJr

  • Active Member
  • ***
  • Posts: 78
  • Karma: +6/-0
    • SocialGratis.com
Re: Etano facebook connect
« Reply #18 on: May 06, 2015, 04:28:37 PM »
BTW, you can retrieve the variables for use as so

Code: [Select]
$femail = $graphObject['email'];
$_SESSION['femail']  = $_GET['whatever you need this to be'];

If you were using this to capture email for etano join:

Code: [Select]
$femail = $graphObject['email'];
$_SESSION['femail']  = $_GET['email'];
$_SESSION['femail']  = $_GET['email2'];

sarthakinfotech

  • Confirmed Member
  • **
  • Posts: 4
  • Karma: +0/-0
Re: Etano facebook connect
« Reply #19 on: May 06, 2015, 08:26:14 PM »
Hi
really great info.


I am working on it once complete will post here the details.



Good day.
sarthakinfotech.

sante

  • Active Member
  • ***
  • Posts: 26
  • Karma: +0/-0
Re: Etano facebook connect
« Reply #20 on: May 07, 2015, 03:00:07 PM »
AH FANTASATIC JuanMartin! Thanks!!

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1006
  • Karma: +56/-7
Re: Etano facebook connect
« Reply #21 on: May 09, 2015, 05:45:00 PM »
I downloaded the zip file but I don't see the fb.config file anywhere in it. Did I not download the right file?
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

JohnHarperJr

  • Active Member
  • ***
  • Posts: 78
  • Karma: +6/-0
    • SocialGratis.com
Re: Etano facebook connect
« Reply #22 on: May 10, 2015, 11:20:20 PM »
Sorry, I got the sdk initially from here, which had the fbconfig file already included:

http://www.krizna.com/general/login-with-facebook-using-php/

You can also use the instructions there to help you with installation. But their FBconfig file didn't work for me out of the box. I had to modify it, especially if I wanted the user's email. Facebook has changed the script to require that you ask a Facebook user for extra permissions to get his or her email.

JohnHarperJr

  • Active Member
  • ***
  • Posts: 78
  • Karma: +6/-0
    • SocialGratis.com
Re: Etano facebook connect
« Reply #23 on: May 11, 2015, 11:49:11 AM »
Here is the link to the list of Facebook Graph properties that you can pull from someones profile, along with whether they are provided by default or have to be accessed with special permissions.

https://developers.facebook.com/docs/facebook-login/permissions/v2.3

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1006
  • Karma: +56/-7
Re: Etano facebook connect
« Reply #24 on: May 11, 2015, 09:16:17 PM »
Thanks!
If a member has a Facebook account and joins an Etano site with their Facebook account and the later deletes their Facebook account, will they lose access to the Etano site?
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

JohnHarperJr

  • Active Member
  • ***
  • Posts: 78
  • Karma: +6/-0
    • SocialGratis.com
Re: Etano facebook connect
« Reply #25 on: May 12, 2015, 01:31:08 AM »
Not the way I have mine set up. I have it doing one click register, and if the user is found it logs them in. But I'm still polishing it. Also, don't use GET statements if possible, that was just a simple basic example.

Marble

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 1006
  • Karma: +56/-7
Re: Etano facebook connect
« Reply #26 on: May 12, 2015, 09:11:48 AM »
does the functions.php file need to be edited?
If you see that I'm logged in forever... it just means I turned the page on my browser and forgot to logout.

JohnHarperJr

  • Active Member
  • ***
  • Posts: 78
  • Karma: +6/-0
    • SocialGratis.com
Re: Etano facebook connect
« Reply #27 on: May 12, 2015, 07:39:22 PM »
I don't even use the file. It all depends on what you want to do and on what conditions you are able to, or want to, in order to get it all set up.

I use email to log my users in verses a username. I have the fb.config file POST the parameters to a modified copy of the join.php file in /processors after the user authenticates through Facebook. If the join file searches my database and finds your email, it logs you in, no password required. If not, it registers you with a new account and then logs you in, and sends a generated password to the user's email that he or she can get later. 

umbro

  • Confirmed Member
  • **
  • Posts: 4
  • Karma: +0/-0
Re: Etano facebook connect
« Reply #28 on: August 13, 2015, 12:29:51 AM »
update download links please ! :)