Jump to content
stylesoft

CONTRIBUTION ez Social Login for Google Facebook LinkedIn Microsoft

Recommended Posts

I've written a simple Social Login that addresses the issues of how complicated these types of add-on's can be.

 

No middlemen required - say goodbye to LoginRadius.

 

* This is the easiest and friendliest social login contrib for osCommerce.
* Written for maximum browser compatibility (IE7 to IE11, Chrome, Firefox and Opera)
* Written for minimum changes to the base osCommerce files.
* Written to make it super simple to integrate with osCommerce.
 
0 database changes
1 osCommerce file to modify with just 1 entry
1 configuration file to edit
3 different visual layouts
4 providers (Google, Facebook, LinkedIn, Microsoft)
 
Less than 20 files in total
No cURL
No Javascript
No HTML5
No Popups
Just pure PHP with a little HTML
 
Tested in 2.3.4 and 2.3.3
 
 
Happy to modify for lower versions of osCommerce with the use of more settings options - just ask.
Happy to add more providers - just ask.
If you want to draw your own perhaps smaller provider buttons, please do so and send to me, i'll include them in the next version.
 

post-262950-0-07588900-1421504241_thumb.png

Edited by stylesoft

Share this post


Link to post
Share on other sites

Hi,

 

just tested it on your demo site. I have logged in with a Google account. Works flawlessly! But: In this Google account, only my email address is stored. After login with the tool I can go through the checkout process without having my name and my address stored somewhere.

What does a shop owner do when an order comes in, where he has only an email address of the customer?
Wouldn't it be better to add a routine to the tool, which verifies that all address details required for an order are available and if necessary ask customers to complement them?
 
J.J.

Share this post


Link to post
Share on other sites

Hi,

 

Very good point, my own website is downloadable goods only.

 

I'm unsure how you managed to social log-in without a name however, looking at the DB I can see 1 entry without a name, almost as if google didn't provide it.

I'll have to recheck the name verification and ask for the name if it is missing.

 

If I wrote up a page asking for:

 
Street Address:  *
Suburb:
Post Code:  *
City:  *
State/Province:  *
Country:  *
Telephone Number:  *

 

Would that cover it for you ?

I'll add options to turn these fields on or off.

 

Regards

Edited by stylesoft

Share this post


Link to post
Share on other sites

Hi All,

Version 1.01 is now complete. try it here:

http://ezsocial.parkbenchgames.com/login.php

 

I added the standard signup form from oc 2.3.4, for data not provided by the social login provider.

 

Fixed a few bugs.

 

Would love for someone to try it in the field to see how it goes.

 

If you use a version less than oc 2.3.4 and have trouble, just post your version and the problem, i'll release a version that works for any reasonable oc version.

 

Regards

 

-Chris

Share this post


Link to post
Share on other sites

Using 2.3.4

 

Getting the following error:

 

Fatal error: Call to undefined function hex2bin() in /home/content/80/6774480/html/tradeshowbestbuy/catalog/ezsocial/functions.php on line 22

 

Has anyone else gotten this?

Share this post


Link to post
Share on other sites

Great contribution! However, I am having an issue.

I have installed "Member Approval" addon which creates a new sql database query called 'member_level' and has a default value of '0'.

I was wondering if you could assist with with ezsocial_success.php file to get it running properly with this plugin. I assume it would be a matter of adding that database query to the ezsocial file...

 

Share this post


Link to post
Share on other sites

I'd like to try it.

But I have a problem with the actual version.

I have this message : Parse error: syntax error, unexpected T_VARIABLE in /home/ioswtyrv/www/ezsocial/oauth_client.php on line 1560
or this one : 
Parse error: syntax error, unexpected '{' in /home/ioswtyrv/www/ezsocial/oauth_client.php on line 1559

I have osCommerce Online Merchant v2.2 RC2a and my site is http://www.ios.fr/.

I put th code in login here :

<?php

  if ($messageStack->size('login') > 0) {
?>
      <tr>
        <td><?php echo $messageStack->output('login'); ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
  }
 
  if ($cart->count_contents() > 0) {
?>
      <tr>
        <td class="smallText"><?php echo TEXT_VISITORS_CART; ?></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
      </tr>
<?php
  }
?>
<?php 
// ezSocial Login contrib start
$ezsocial = file_get_contents('ezsocial/ezsocial.html'); 
echo $ezsocial;
// ezSocial Login contrib end
?>
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main" width="50%" valign="top"><b><?php echo HEADING_NEW_CUSTOMER; ?></b></td>
            <td class="main" width="50%" valign="top"><b><?php echo HEADING_RETURNING_CUSTOMER; ?></b></td>
          </tr>
          <tr>
            <td width="50%" height="100%" valign="top"><table border="0" width="100%" height="100%" cellspacing="1" cellpadding="2" class="infoBox">
              <tr class="infoBoxContents">
                <td><table border="0" width="100%" height="100%" cellspacing="0" cellpadding="2">

Thank's for your work.

J.Green

 

Share this post


Link to post
Share on other sites

as a matter of fact it doesnt work on my standard install of OSC 3.4 either.

The ezsocial_success.php page loads a blank white page and does not redirect back to the site or log you in.

Share this post


Link to post
Share on other sites

I get the same error, Its a PHP version issue.  Not sure if there is a work around for this or not.

 

 

Using 2.3.4

 

Getting the following error:

 

Fatal error: Call to undefined function hex2bin() in /home/content/80/6774480/html/tradeshowbestbuy/catalog/ezsocial/functions.php on line 22

 

Has anyone else gotten this?

Share this post


Link to post
Share on other sites

Thanks for this add-on . I have implemented this addon. Login with google is working fine. But Login with facebook gives an errorr .The error is: App Not Setup: The developers of this app have not set up this app properly for Facebook Login. Even the demo page in addon gives same error.  

 

Please help as soon as possible.Thanks ...

Share this post


Link to post
Share on other sites

Thanks for this add-on . I have implemented this addon. Login with google is working fine. But Login with facebook gives an errorr .The error is: App Not Setup: The developers of this app have not set up this app properly for Facebook Login. Even the demo page in addon gives same error.  

 

Please help as soon as possible.Thanks ...

 

Have you setup your facebook app properly? please update the app id and secret key in the file as well.

Share this post


Link to post
Share on other sites

Thanks for this add-on.

 

Solution for this bug, i fix it in my code

Fatal error: Call to undefined function hex2bin() in /home/content/80/6774480/html/tradeshowbestbuy/catalog/ezsocial/functions.php on line 22

 

please add this function in functions.php file. hex2bin  work in php>=5.4.0 

 

if ( !function_exists( 'hex2bin' ) ) {

    function hex2bin( $str ) {
        $sbin = "";
        $len = strlen( $str );
        for ( $i = 0; $i < $len; $i += 2 ) {
            $sbin .= pack( "H*", substr( $str, $i, 2 ) );
        }
 
        return $sbin;
    }
}

 

From

Imran Sadiq

pakistan

Share this post


Link to post
Share on other sites

Google sign in works for me, but Facebook acts like it will work but after redirect from FB it says 'Social Login Failure, please go back and try again.' I followed all instructions, so I don't know why it's not working. xd

Share this post


Link to post
Share on other sites

Google sign in kind of works , Facebook it doesnt and returns an error ...

 

Cant check FB login details because of an error ..

 

For the Login with Google:

While it sounds good to be able to login with Google account.....  I still don't see any point logging in with Google if ONLY Name, Surname and Email are retreived from an usual Google account setup .. while oscommerce needs also other Required fields for most shops in order to send the goods somewhere ...

 

In this way the customer only gets confused as we give him/her a feeling that the login / create account proceedure will be somehow shorten, but .. than the customer still needs to enter most of the rquired info anyway ..

Share this post


Link to post
Share on other sites

But Login with facebook gives an errorr .The error is: App Not Setup: The developers of this app have not set up this app properly for Facebook Login. Even the demo page in addon gives same error.

 

 

In your Facebook App Settings, make sure you have a contact email address under "Settings > Basic", then enable your app in "Status & Review"

 

That will get your customers to the facebook authorize screen, but pressing "Okay" displays the following error

 

"Facebook Social Login Error: Social Login was unable to get your email address Please either sign up normally, use another social provider login or re-enable email authorization for this website"

 

This is the string that gets passed back to my site before failing. 

 

login_with_facebook.php?code=AQBIC_5QjXElifxxI0Yl4kWAXBEu30L0AvQa0zCyjWDM6CP-OGcSyt9AL7NiSFDdWh4lQJpcuUnMceXjTBCqYkioyTXHEduYBcK3voLsESkV6aaEKUaaXzSYDTqQUbeGAEIrAvFytnIbobKvMGSKhKCOUWl-eqsZLC1YaOan5xWf53FhEKubdvqAnbEWHK9d3gzFq7LV2CLZw46v2zqOe37aIAcgfn4RPnSKjjx8toP3JWnNWEdNqBbQiVUnzmpxhzDiWaDg94VHOqnGvzDUnVpBT140FRhayXvh9SoXTvmdBtKix6G7VaSCvh36fV0lsR8V4zLuxJfVzvwtFJ1nGxGM&state=1443251028-3599a5#_=_

 

Anyone know how to fix it? All other providers working fine

 

BIG thanks to stylesoft for this great contribution

Share this post


Link to post
Share on other sites

High kudos to @@stylesoft for an amazing attempt to solve a never ending challenge for shop owners and their customers.  I was ecstatic to find this contribution and eager to install until I realized that the support forum isn't being monitored.

 

Has anyone found a similar contribution that works well and for which the support forum is being monitored?

 

Appreciate any guidance!


Anthony David

AllThingsTrendy.com

Share this post


Link to post
Share on other sites

Guys, I did it!! Facebook social login finally working  :thumbsup:

 

Edit login_with_facebook.php and replace the "GET array" line under 'https://graph.facebook.com/me' with the following

                                        'GET', array(
                                                'fields'=>'first_name,last_name,gender,email'
                                        ), array('FailOnAccessError'=>true), $user);

Edited by jackhill

Share this post


Link to post
Share on other sites

 

Guys, I did it!! Facebook social login finally working  :thumbsup:

 

Edit login_with_facebook.php and replace the "GET array" line under 'https://graph.facebook.com/me' with the following

                                        'GET', array(
                                                'fields'=>'first_name,last_name,gender,email'
                                        ), array('FailOnAccessError'=>true), $user);

 

Hmmm.... tried your fix, still can't get it to login :(

 

Getting: Social Login Failure, please go back and try again.

 

And when outputting the error i get:

it was not possible to open the OAuth access token URL: 0 could not connect to the host "graph.facebook.com"

 

Could you share your login_with_facebook.php? :)

Share this post


Link to post
Share on other sites

Hmmm.... tried your fix, still can't get it to login :(

 

Getting: Social Login Failure, please go back and try again.

 

And when outputting the error i get:

it was not possible to open the OAuth access token URL: 0 could not connect to the host "graph.facebook.com"

 

Could you share your login_with_facebook.php? :)

 

Here you go

<?php
/*
 * login_with_facebook.php
 *
 * Modified for ezSocial contrib for osCommerce by Christopher Trigg Jan 2015
 *
 * @(#) $Id: login_with_facebook.php,v 1.3 2013/07/31 11:48:04 mlemos Exp $
 *
 */

        require('ezsocial/settings.php');
        require('ezsocial/functions.php');
        require('ezsocial/http.php');
        require('ezsocial/oauth_client.php');

        $ezsocial_uri = $ezsocial_protocol.$_SERVER['HTTP_HOST'].dirname(strtok($_SERVER['REQUEST_URI'],'?'));
        if(substr($ezsocial_uri, -1) != '/')
                $ezsocial_uri .= '/';
        $ezsocial_uri .= 'login_with_facebook.php';

        $client = new oauth_client_class;
        $client->debug = false;
        $client->debug_http = false;
        $client->display = "popup";
        $client->server = 'Facebook';
        $client->redirect_uri = $ezsocial_uri;
        $client->client_id = $ezsocial_facebook_client_id;
        $client->client_secret = $ezsocial_facebook_client_secret;

        $client->scope = 'email';
        if(($success = $client->Initialize())) {
                if(($success = $client->Process())) {
                        if(strlen($client->access_token)) {
                                $success = $client->CallAPI(
                                        'https://graph.facebook.com/me',
                                        'GET', array(
                                                'fields'=>'first_name,last_name,gender,email'
                                        ), array('FailOnAccessError'=>true), $user);
                        }
                }
                $success = $client->Finalize($success);
        }
        if($client->exit)
                exit;
        if($success) {
                if($ezsocial_debug_uri) {
                        echo("REDIRECT URI: ".$ezsocial_uri);
                        exit();
                }
                if($ezsocial_debug_errors) {
                        error_log("ezSocial: Provider data: ".print_r($user,true));
                }
                require('includes/application_top.php');

                if(isset($user->email) && (strlen($user->email) > 3))
                        $email = $user->email;
                else {
                        echo "Facebook Social Login Error:"."\n";
                        echo $ezsocial_email_missing;
                        exit();
                }

                if(isset($user->first_name) && (strlen($user->first_name) > 0))
                        $first = $user->first_name;
                else
                        $first = 'Unknown';

                if(isset($user->last_name) && (strlen($user->last_name) > 0))
                        $last = $user->last_name;
                else
                        $last = 'Unknown';

                if(isset($user->gender) && (strlen($user->gender) > 0))
                        $gender = $user->gender;
                else
                        $gender = 'Unknown';

                if($gender == 'male')
                        $gender = 'm';
                else if($gender == 'female')
                        $gender = 'f';

                $ezsocial_t = (string) ceil(time()/60);
                $ezsocial_data = 'ezsocial|'.$ezsocial_t.'|facebook|'.$first.'|'.$last.'|'.$gender.'|'.$email;
                $ezsocial_hash = mc_encrypt($ezsocial_data, ezsocial_get_key());
                tep_redirect('ezsocial_success.php?login='.$ezsocial_hash);
        } else  {
                echo "Social Login Failure, please go back and try again";
        }

?>

Make sure you have the latest version of EZSocial installed

Edited by jackhill

Share this post


Link to post
Share on other sites

 

Guys, I did it!! Facebook social login finally working  :thumbsup:

 

Edit login_with_facebook.php and replace the "GET array" line under 'https://graph.facebook.com/me' with the following

                                        'GET', array(
                                                'fields'=>'first_name,last_name,gender,email'
                                        ), array('FailOnAccessError'=>true), $user);

It still doesn't work, I get following message when I click on Refresh User Acces Token:

in dutch:

De opgegeven URL wordt niet toegestaan door de configuratie van de applicatie.: Een of meer van de opgegeven URL's zijn niet toegestaan door de instellingen van de app. De URL moet overeenkomen met de website- of canvas-URL, of het domein moet een subdomein zijn van een van de domeinen van de app.

in english:

the given URL is not permitted for configureation of the application: one or more of the given URL's are not permitted. The URL most be the same as the website of canvas URL' , or the domain must be a sub domain of the domains of the App

I did fill in the website url in the setting menu (add platform)

 

What can it be ?

 

With kind regards,

Peter

Share this post


Link to post
Share on other sites

 

I did fill in the website url in the setting menu (add platform)

 

You didn't add the correct callback URI

 

Go to your facebook app and click Settings -> Advanced

 
Enter the callback URI under "Valid OAuth redirect URIs"
 
Click Save Changes at the bottom
Edited by jackhill

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×