Osclass forums

Support forums => Plugins => Facebook Connect => Topic started by: SteveJohnson on October 19, 2015, 11:18:12 pm

Title: Please confirm here - if the FB plugin works
Post by: SteveJohnson on October 19, 2015, 11:18:12 pm
Hello people,

I'd like to ask you all to confirm if there actually is a bug in the FB plugin, or does it work for someone. Please comment with your OSclass version and write if the plugin works for you. This post is more like a poll.
I'll start with my comment below.
Title: Re: Please confirm here - if the FB plugin works
Post by: SteveJohnson on October 19, 2015, 11:21:43 pm
Osclass version - 3.5.7
Facebook plugin does not work.
Title: Re: Please confirm here - if the FB plugin works
Post by: alex2000 on November 03, 2015, 02:08:38 am
tried with 3.5.7, 3.5.9 can't make it work, it looks like something going wrong and also nobody on here can help
Title: Re: Please confirm here - if the FB plugin works
Post by: SteveJohnson on November 08, 2015, 03:35:05 am
The theme that i'm using used the FB setup inbuilt from this plugin itself, but the newer version has excluded using this. Seems the plugin does not work afterall.
Title: Re: Please confirm here - if the FB plugin works
Post by: aryankamgar on January 07, 2016, 02:03:59 am
Yes it doesn't work for me too
Title: Re: Please confirm here - if the FB plugin works
Post by: aide2006 on January 08, 2016, 01:07:16 pm
OSCLASS 3.2 works fine with FB Plugin
Title: Re: Please confirm here - if the FB plugin works
Post by: issam.taboubi on January 29, 2016, 07:58:52 am
Hi all,

I have fixed the problem. It work perfectly .

Contact me if you want a fix.
Title: Re: Please confirm here - if the FB plugin works
Post by: SteveJohnson on February 01, 2016, 06:37:23 pm
Hi all,

I have fixed the problem. It work perfectly .

Contact me if you want a fix.

Hello. Could you share the solution here, so others can fix it too?
Regards,
Title: Re: Please confirm here - if the FB plugin works
Post by: pecke on February 26, 2016, 02:33:19 am
Work on my site  version 3.6.1
Title: Re: Please confirm here - if the FB plugin works
Post by: ehalvorsen1 on February 26, 2016, 12:48:37 pm
V3.6.1 Not working for me
Title: Re: Please confirm here - if the FB plugin works
Post by: onaldo on March 05, 2016, 06:20:08 am
Hi all,

I have fixed the problem. It work perfectly .

Contact me if you want a fix.

Please be of help and post it here. Thanks.
Title: Re: Please confirm here - if the FB plugin works
Post by: Pirulina on March 05, 2016, 09:26:31 am
I have set up the aplication on FB, i got it to work once only, then it would just return me to homepage without signing in, what do you guys think is wrong? (same with Google plugin) I'm using theme Zara. Thanks.
Title: Re: Please confirm here - if the FB plugin works
Post by: chobuon_com on April 10, 2017, 08:47:17 pm
Facebook Login need update to latest Facebook SDK version. This a old version.
Title: Re: Please confirm here - if the FB plugin works
Post by: thecarius on April 21, 2017, 11:59:27 pm
Hi, does anyone have the facebook solution?
Title: Re: Please confirm here - if the FB plugin works
Post by: ColdFusion on May 30, 2017, 07:05:53 pm
Guys, there are some people saying they manged to run this in the reviews section, but links are removed. If anyone knows the link to the solution, could you post it here, please. There is a user called oclass-ian that mentions a solution, but again link is missing. If anyone with PM rights can message him would be great.

Thanks
Title: Re: Please confirm here - if the FB plugin works
Post by: jay63 on May 31, 2017, 06:30:00 pm
the plugin facebook connect don't works on osclass.

I use the free plugin Version:1.4.1 | Par OSClass  on osclass 3.5.9, but it don't work : the authentication with facebook works but the table t_facebook_connect stay blanks and no user can to log on my site...

connection with facebook don't work. Have you a solution ?
Can you help me
Thanks a lot
Title: Re: Please confirm here - if the FB plugin works
Post by: jay63 on June 01, 2017, 11:57:55 am
No solution ?
Title: Re: Please confirm here - if the FB plugin works
Post by: ColdFusion on June 01, 2017, 08:19:11 pm
No solution ?

Unfortunately, the quick solution is to buy the Social Connect - quite pricey, but works. And I guess that explains why they don't care about the free one not working...
Title: Re: Please confirm here - if the FB plugin works
Post by: SteveJohnson on June 02, 2017, 09:27:12 am
There's no point continuing this thread.
We know this plugin will ofcourse not be continued, obvious reasons.
Title: Re: Please confirm here - if the FB plugin works
Post by: jay63 on June 06, 2017, 04:13:05 pm
so, if all plugin on osclass become paying, so I stop Osclass... the open source disappears
Title: Re: Please confirm here - if the FB plugin works
Post by: chobienmau_com on September 29, 2017, 08:28:32 pm
you want this plugin work on latest osclass and facebook api now you must upgrade this plugin to facebook sdk v5. Follow step.

1. replace all file in facebook/src/* (sdk v5)

2. Replace OSCFacebook.php

Code: [Select]
<?php

    
/**
     * OSClass – software for creating and publishing online classified advertising platforms
     *
     * Copyright (C) 2010 OSCLASS
     *
     * This program is free software: you can redistribute it and/or modify it under the terms
     * of the GNU Affero General Public License as published by the Free Software Foundation,
     * either version 3 of the License, or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     * See the GNU Affero General Public License for more details.
     *
     * You should have received a copy of the GNU Affero General Public
     * License along with this program. If not, see <http://www.gnu.org/licenses/>.
     */

    // Include the autoloader provided in the SDK
    
require_once dirname__FILE__ ) . '/src/autoload.php';

    
// Include required libraries
    
use Facebook\Facebook;
    use 
Facebook\Exceptions\FacebookResponseException;
    use 
Facebook\Exceptions\FacebookSDKException;


    class 
OSCFacebook extends DAO
    
{
        private static 
$instance;
        private static 
$facebook;
        private static 
$user;
        private static 
$loginUrl;
        private static 
$logoutUrl;
        private static 
$user_profile;

        public static function 
newInstance()
        {
            if(!
self::$instance instanceof self) {
                
self::$instance = new self;
            }

            return 
self::$instance;
        }

        public function 
__construct()
        {
            
parent::__construct();
            
$this->setTableName't_facebook_connect' );
            
$this->setPrimaryKey'fk_i_user_id' );
            
$this->setFields( array( 'fk_i_user_id''i_facebook_uid' ) );


            
self::$facebook = new Facebook(array(
                
'app_id'  => 'YOUR APP ID',
                
'app_secret' => 'YOUR APP SECRET',
                
'default_graph_version' => 'v2.10'
            
));

        }

        public function 
init() {

            
// Get redirect login helper
            
$helper self::$facebook->getRedirectLoginHelper();

            
// Try to get access token
            
try {
                if(isset(
$_SESSION['facebook_access_token'])){
                    
$accessToken $_SESSION['facebook_access_token'];
                }else{
                    
$accessToken $helper->getAccessToken();
                }
            } catch(
FacebookResponseException $e) {
                echo 
'Graph returned an error: ' $e->getMessage();
                exit;
            } catch(
FacebookSDKException $e) {
                echo 
'Facebook SDK returned an error: ' $e->getMessage();
                exit;
            }

            if(isset(
$accessToken)){

                if(isset(
$_SESSION['facebook_access_token'])){
                    
self::$facebook->setDefaultAccessToken($_SESSION['facebook_access_token']);
                }else{
                    
// Put short-lived access token in session
                    
$_SESSION['facebook_access_token'] = (string) $accessToken;
                    
                    
// OAuth 2.0 client handler helps to manage access tokens
                    
$oAuth2Client self::$facebook->getOAuth2Client();
                    
                    
// Exchanges a short-lived access token for a long-lived one
                    
$longLivedAccessToken $oAuth2Client->getLongLivedAccessToken($_SESSION['facebook_access_token']);
                    
$_SESSION['facebook_access_token'] = (string) $longLivedAccessToken;
                    
                    
// Set default access token to be used in script
                    
self::$facebook->setDefaultAccessToken($_SESSION['facebook_access_token']);
                }

                
// Redirect the user back to the same page if url has "code" parameter in query string
                
if(isset($_GET['code'])){
                    
header('Location: ./');
                }

                

                
// Getting user facebook profile info
                
try {
                    
$profileRequest self::$facebook->get('/me?fields=name,first_name,last_name,email,link,gender,locale,picture');
                    
self::$user_profile $profileRequest->getGraphNode()->asArray();
                } catch(
FacebookResponseException $e) {
                    echo 
'Graph returned an error: ' $e->getMessage();
                    
self::$facebook->destroySession();
                    
// Redirect user back to app login page
                    
header("Location: ./");
                    exit;
                } catch(
FacebookSDKException $e) {
                    echo 
'Facebook SDK returned an error: ' $e->getMessage();
                    exit;
                }

                
self::$user $this->getUser();

                if ( !
self::$user ) {
                    return 
self::$facebook;
                }

                try {
                    
$this->dao->select$this->getFields() );
                    
$this->dao->from$this->getTableName() );
                    
$this->dao->where'i_facebook_uid'self::$user );

                    
$rs $this->dao->get();

                    if( ( 
$rs !== false ) && ( $rs->numRows() === ) ) {
                        
$fbUser $rs->row();
                        if( 
count($fbUser) > ) {
                            require_once 
osc_lib_path() . 'osclass/UserActions.php';
                            
$uActions = new UserActionsfalse );
                            
$logged   $uActions->bootstrap_login$fbUser['fk_i_user_id'] );

                            switch( 
$logged ) {
                                case 
0osc_add_flash_error_message__'The username doesn\'t exist''facebook' ) );
                                break;
                                case 
1osc_add_flash_error_message__'The user has not been validated yet''facebook' ) );
                                break;
                                case 
2osc_add_flash_error_message__'The user has been suspended''facebook' ) );
                                break;
                            }
                            return 
self::$facebook;
                        }
                    }

                    if(
is_null(self::$user_profile)) {
                        if (isset(
$_SERVER['HTTP_COOKIE'])) {
                            
$cookies explode(';'$_SERVER['HTTP_COOKIE']);
                            foreach (
$cookies as $cookie) {
                                
$parts explode('='$cookie);
                                
$name trim($parts[0]);
                                
setcookie($name''time() - 1000);
                                
setcookie($name''time() - 1000'/');
                            }
                        }

                        
osc_add_flash_error_message(__('Some error occured trying to connect with Facebook.''facebook'));
                        
header'Location: ' osc_register_account_url()  );
                        exit();
                    } else{
                        if( !isset(
self::$user_profile['email']) ) {

                            if (isset(
$_SERVER['HTTP_COOKIE'])) {
                                
$cookies explode(';'$_SERVER['HTTP_COOKIE']);
                                foreach (
$cookies as $cookie) {
                                    
$parts explode('='$cookie);
                                    
$name trim($parts[0]);
                                    
setcookie($name''time() - 1000);
                                    
setcookie($name''time() - 1000'/');
                                }
                            }

                            
osc_add_flash_error_message(__('Some error occured trying to connect with Facebook.''facebook'));
                            
header'Location: ' osc_register_account_url() );
                            exit();
                        }
                    }

                    
$manager User::newInstance();
                    
$oscUser $manager->findByEmailself::$user_profile['email'] );
                    
// exists on our DB, we merge both accounts
                    
if( count($oscUser) > ) {
                        require_once 
osc_lib_path() . 'osclass/UserActions.php';
                        
$uActions = new UserActionsfalse );

                        
$manager->dao->from$this->getTableName() );
                        
$manager->dao->set'fk_i_user_id'$oscUser['pk_i_id'] );
                        
$manager->dao->set'i_facebook_uid'self::$user_profile['id'] );
                        
$manager->dao->insert();
                        
// activate user in case is not activated
                        
$manager->update( array('b_active' => '1'), array('pk_i_id' => $oscUser['pk_i_id']) );
                        
$logged $uActions->bootstrap_login$oscUser['pk_i_id'] );
                        
osc_add_flash_ok_message__"You already have an user with this e-mail address. We've merged your accounts"'facebook' ) );
                    } else {
                        
// Auto-register him
                        
$this->register_userself::$user_profile );
                    }

                    
// redirect to log in
                    
header'Location: ' osc_base_url() );
                    exit;


                } catch (
FacebookApiException $e) {
                    
self::$user null;
                }

                return 
self::$facebook;

            } else {
                
// Get login url
                
if( !osc_is_web_user_logged_in() ) {
                    
self::$loginUrl  $helper->getLoginUrlosc_base_url(), array('scope' => 'email'));
                }
            }
            
        }

        public function 
import$file )
        {
            
$path osc_plugin_resource$file );
            
$sql  file_get_contents$path );

            if( !
$this->dao->importSQL$sql ) ) {
                throw new 
Exception__('Error importing the database structure of the jobboard plugin''jobboard') );
            }
        }

        public function 
uninstall()
        {
            
$this->resetCookies();
            
$this->dao->query'DROP TABLE ' $this->getTableName() );
        }

        public function 
getFacebook()
        {
            return 
self::$facebook;
        }

        public function 
getUser()
        {
            if( 
self::$user == null ) {
                
self::$user self::$user_profile['id'];
            }

            return 
self::$user;
        }

        public function 
getUsername() 
        {
            if( 
self::$user_profile['email'] != null ) {
                
$splusername explode('@'self::$user_profile['email']);
                
$username $splusername[0];
            }
            return 
$username;
        }

        public function 
logoutUrl()
        {
            return 
self::$logoutUrl;
        }

        public function 
loginUrl()
        {
            return 
self::$loginUrl;
        }

        public function 
profile()
        {
            if( 
self::$user_profile == null ) {
                
self::$user_profile self::$facebook->get'/me?fields=name,first_name,last_name,email,link,gender,locale,picture' );
            }

            return 
self::$user_profile;
        }

        private function 
register_user($user)
        {
            
$manager User::newInstance();

            
$input['s_name']      = $user['name'];
            
$input['s_username']  = $this->getUsername();
            
$input['s_email']     = $user['email'];
            
$input['s_password']  = sha1osc_genRandomPassword() );
            
$input['dt_reg_date'] = date'Y-m-d H:i:s' );
            
$input['s_secret']    = osc_genRandomPassword();
            
$input['b_active']    = 1;

            
$email_taken $manager->findByEmail$input['s_email'] );
            if(
$email_taken == null) {
                
$manager->insert$input );
                
$userID $manager->dao->insertedId();

                
$manager->dao->from$this->getTableName() );
                
$manager->dao->set'fk_i_user_id'$userID );
                
$manager->dao->set'i_facebook_uid'$user['id'] );
                
$result $manager->dao->replace();

                if( 
$result == false ) {
                    
// error inserting user
                    
return false;
                }

                
osc_run_hook'user_register_completed'$userID );

                
$userDB $manager->findByPrimaryKey$userID );

                if( 
osc_notify_new_user() ) {
                    
osc_run_hook'hook_email_admin_new_user'$userDB );
                }

                
osc_run_hook('hook_email_user_registration'$userDB);
                
osc_run_hook('validate_user'$userDB);

                
osc_add_flash_ok_messagesprintf__('Your account has been created successfully''facebook' ), osc_page_title() ) );
                return 
true;
            }
        }

        public function 
resetCookies()
        {
            
//self::$facebook->destroySession();
            // Remove access token from session
            
unset($_SESSION['facebook_access_token']);

            
// Remove user data from session
            
unset($_SESSION['userData']);
        }
    }

    
/* file end: ./oc-content/plugins/facebook/OSCFacebook.php */
?>


3. Try
Title: Re: Please confirm here - if the FB plugin works
Post by: chobienmau_com on October 01, 2017, 05:36:57 am
i am worked on this plugin 24 hours and it working on facebook api v2.10. demo chobienmau.com
Title: Re: Please confirm here - if the FB plugin works
Post by: blblago on November 20, 2017, 12:57:48 pm
you want this plugin work on latest osclass and facebook api now you must upgrade this plugin to facebook sdk v5. Follow step.

1. replace all file in facebook/src/* (sdk v5)

2. Replace OSCFacebook.php

Code: [Select]
<?php

    
/**
     * OSClass – software for creating and publishing online classified advertising platforms
     *
     * Copyright (C) 2010 OSCLASS
     *
     * This program is free software: you can redistribute it and/or modify it under the terms
     * of the GNU Affero General Public License as published by the Free Software Foundation,
     * either version 3 of the License, or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     * See the GNU Affero General Public License for more details.
     *
     * You should have received a copy of the GNU Affero General Public
     * License along with this program. If not, see <http://www.gnu.org/licenses/>.
     */

    // Include the autoloader provided in the SDK
    
require_once dirname__FILE__ ) . '/src/autoload.php';

    
// Include required libraries
    
use Facebook\Facebook;
    use 
Facebook\Exceptions\FacebookResponseException;
    use 
Facebook\Exceptions\FacebookSDKException;


    class 
OSCFacebook extends DAO
    
{
        private static 
$instance;
        private static 
$facebook;
        private static 
$user;
        private static 
$loginUrl;
        private static 
$logoutUrl;
        private static 
$user_profile;

        public static function 
newInstance()
        {
            if(!
self::$instance instanceof self) {
                
self::$instance = new self;
            }

            return 
self::$instance;
        }

        public function 
__construct()
        {
            
parent::__construct();
            
$this->setTableName't_facebook_connect' );
            
$this->setPrimaryKey'fk_i_user_id' );
            
$this->setFields( array( 'fk_i_user_id''i_facebook_uid' ) );


            
self::$facebook = new Facebook(array(
                
'app_id'  => 'YOUR APP ID',
                
'app_secret' => 'YOUR APP SECRET',
                
'default_graph_version' => 'v2.10'
            
));

        }

        public function 
init() {

            
// Get redirect login helper
            
$helper self::$facebook->getRedirectLoginHelper();

            
// Try to get access token
            
try {
                if(isset(
$_SESSION['facebook_access_token'])){
                    
$accessToken $_SESSION['facebook_access_token'];
                }else{
                    
$accessToken $helper->getAccessToken();
                }
            } catch(
FacebookResponseException $e) {
                echo 
'Graph returned an error: ' $e->getMessage();
                exit;
            } catch(
FacebookSDKException $e) {
                echo 
'Facebook SDK returned an error: ' $e->getMessage();
                exit;
            }

            if(isset(
$accessToken)){

                if(isset(
$_SESSION['facebook_access_token'])){
                    
self::$facebook->setDefaultAccessToken($_SESSION['facebook_access_token']);
                }else{
                    
// Put short-lived access token in session
                    
$_SESSION['facebook_access_token'] = (string) $accessToken;
                    
                    
// OAuth 2.0 client handler helps to manage access tokens
                    
$oAuth2Client self::$facebook->getOAuth2Client();
                    
                    
// Exchanges a short-lived access token for a long-lived one
                    
$longLivedAccessToken $oAuth2Client->getLongLivedAccessToken($_SESSION['facebook_access_token']);
                    
$_SESSION['facebook_access_token'] = (string) $longLivedAccessToken;
                    
                    
// Set default access token to be used in script
                    
self::$facebook->setDefaultAccessToken($_SESSION['facebook_access_token']);
                }

                
// Redirect the user back to the same page if url has "code" parameter in query string
                
if(isset($_GET['code'])){
                    
header('Location: ./');
                }

                

                
// Getting user facebook profile info
                
try {
                    
$profileRequest self::$facebook->get('/me?fields=name,first_name,last_name,email,link,gender,locale,picture');
                    
self::$user_profile $profileRequest->getGraphNode()->asArray();
                } catch(
FacebookResponseException $e) {
                    echo 
'Graph returned an error: ' $e->getMessage();
                    
self::$facebook->destroySession();
                    
// Redirect user back to app login page
                    
header("Location: ./");
                    exit;
                } catch(
FacebookSDKException $e) {
                    echo 
'Facebook SDK returned an error: ' $e->getMessage();
                    exit;
                }

                
self::$user $this->getUser();

                if ( !
self::$user ) {
                    return 
self::$facebook;
                }

                try {
                    
$this->dao->select$this->getFields() );
                    
$this->dao->from$this->getTableName() );
                    
$this->dao->where'i_facebook_uid'self::$user );

                    
$rs $this->dao->get();

                    if( ( 
$rs !== false ) && ( $rs->numRows() === ) ) {
                        
$fbUser $rs->row();
                        if( 
count($fbUser) > ) {
                            require_once 
osc_lib_path() . 'osclass/UserActions.php';
                            
$uActions = new UserActionsfalse );
                            
$logged   $uActions->bootstrap_login$fbUser['fk_i_user_id'] );

                            switch( 
$logged ) {
                                case 
0osc_add_flash_error_message__'The username doesn\'t exist''facebook' ) );
                                break;
                                case 
1osc_add_flash_error_message__'The user has not been validated yet''facebook' ) );
                                break;
                                case 
2osc_add_flash_error_message__'The user has been suspended''facebook' ) );
                                break;
                            }
                            return 
self::$facebook;
                        }
                    }

                    if(
is_null(self::$user_profile)) {
                        if (isset(
$_SERVER['HTTP_COOKIE'])) {
                            
$cookies explode(';'$_SERVER['HTTP_COOKIE']);
                            foreach (
$cookies as $cookie) {
                                
$parts explode('='$cookie);
                                
$name trim($parts[0]);
                                
setcookie($name''time() - 1000);
                                
setcookie($name''time() - 1000'/');
                            }
                        }

                        
osc_add_flash_error_message(__('Some error occured trying to connect with Facebook.''facebook'));
                        
header'Location: ' osc_register_account_url()  );
                        exit();
                    } else{
                        if( !isset(
self::$user_profile['email']) ) {

                            if (isset(
$_SERVER['HTTP_COOKIE'])) {
                                
$cookies explode(';'$_SERVER['HTTP_COOKIE']);
                                foreach (
$cookies as $cookie) {
                                    
$parts explode('='$cookie);
                                    
$name trim($parts[0]);
                                    
setcookie($name''time() - 1000);
                                    
setcookie($name''time() - 1000'/');
                                }
                            }

                            
osc_add_flash_error_message(__('Some error occured trying to connect with Facebook.''facebook'));
                            
header'Location: ' osc_register_account_url() );
                            exit();
                        }
                    }

                    
$manager User::newInstance();
                    
$oscUser $manager->findByEmailself::$user_profile['email'] );
                    
// exists on our DB, we merge both accounts
                    
if( count($oscUser) > ) {
                        require_once 
osc_lib_path() . 'osclass/UserActions.php';
                        
$uActions = new UserActionsfalse );

                        
$manager->dao->from$this->getTableName() );
                        
$manager->dao->set'fk_i_user_id'$oscUser['pk_i_id'] );
                        
$manager->dao->set'i_facebook_uid'self::$user_profile['id'] );
                        
$manager->dao->insert();
                        
// activate user in case is not activated
                        
$manager->update( array('b_active' => '1'), array('pk_i_id' => $oscUser['pk_i_id']) );
                        
$logged $uActions->bootstrap_login$oscUser['pk_i_id'] );
                        
osc_add_flash_ok_message__"You already have an user with this e-mail address. We've merged your accounts"'facebook' ) );
                    } else {
                        
// Auto-register him
                        
$this->register_userself::$user_profile );
                    }

                    
// redirect to log in
                    
header'Location: ' osc_base_url() );
                    exit;


                } catch (
FacebookApiException $e) {
                    
self::$user null;
                }

                return 
self::$facebook;

            } else {
                
// Get login url
                
if( !osc_is_web_user_logged_in() ) {
                    
self::$loginUrl  $helper->getLoginUrlosc_base_url(), array('scope' => 'email'));
                }
            }
            
        }

        public function 
import$file )
        {
            
$path osc_plugin_resource$file );
            
$sql  file_get_contents$path );

            if( !
$this->dao->importSQL$sql ) ) {
                throw new 
Exception__('Error importing the database structure of the jobboard plugin''jobboard') );
            }
        }

        public function 
uninstall()
        {
            
$this->resetCookies();
            
$this->dao->query'DROP TABLE ' $this->getTableName() );
        }

        public function 
getFacebook()
        {
            return 
self::$facebook;
        }

        public function 
getUser()
        {
            if( 
self::$user == null ) {
                
self::$user self::$user_profile['id'];
            }

            return 
self::$user;
        }

        public function 
getUsername() 
        {
            if( 
self::$user_profile['email'] != null ) {
                
$splusername explode('@'self::$user_profile['email']);
                
$username $splusername[0];
            }
            return 
$username;
        }

        public function 
logoutUrl()
        {
            return 
self::$logoutUrl;
        }

        public function 
loginUrl()
        {
            return 
self::$loginUrl;
        }

        public function 
profile()
        {
            if( 
self::$user_profile == null ) {
                
self::$user_profile self::$facebook->get'/me?fields=name,first_name,last_name,email,link,gender,locale,picture' );
            }

            return 
self::$user_profile;
        }

        private function 
register_user($user)
        {
            
$manager User::newInstance();

            
$input['s_name']      = $user['name'];
            
$input['s_username']  = $this->getUsername();
            
$input['s_email']     = $user['email'];
            
$input['s_password']  = sha1osc_genRandomPassword() );
            
$input['dt_reg_date'] = date'Y-m-d H:i:s' );
            
$input['s_secret']    = osc_genRandomPassword();
            
$input['b_active']    = 1;

            
$email_taken $manager->findByEmail$input['s_email'] );
            if(
$email_taken == null) {
                
$manager->insert$input );
                
$userID $manager->dao->insertedId();

                
$manager->dao->from$this->getTableName() );
                
$manager->dao->set'fk_i_user_id'$userID );
                
$manager->dao->set'i_facebook_uid'$user['id'] );
                
$result $manager->dao->replace();

                if( 
$result == false ) {
                    
// error inserting user
                    
return false;
                }

                
osc_run_hook'user_register_completed'$userID );

                
$userDB $manager->findByPrimaryKey$userID );

                if( 
osc_notify_new_user() ) {
                    
osc_run_hook'hook_email_admin_new_user'$userDB );
                }

                
osc_run_hook('hook_email_user_registration'$userDB);
                
osc_run_hook('validate_user'$userDB);

                
osc_add_flash_ok_messagesprintf__('Your account has been created successfully''facebook' ), osc_page_title() ) );
                return 
true;
            }
        }

        public function 
resetCookies()
        {
            
//self::$facebook->destroySession();
            // Remove access token from session
            
unset($_SESSION['facebook_access_token']);

            
// Remove user data from session
            
unset($_SESSION['userData']);
        }
    }

    
/* file end: ./oc-content/plugins/facebook/OSCFacebook.php */
?>


3. Try

Rus: Огромное спасибо вам за помощь ! Плагин Facebook connect снова работает !

Eng: Many thanks to you for your help! The Facebook connect plug-in works again!
Title: Re: Please confirm here - if the FB plugin works
Post by: rdzdavid on March 22, 2018, 07:14:54 pm
you want this plugin work on latest osclass and facebook api now you must upgrade this plugin to facebook sdk v5. Follow step.

1. replace all file in facebook/src/* (sdk v5)

2. Replace OSCFacebook.php

Code: [Select]
<?php

    
/**
     * OSClass – software for creating and publishing online classified advertising platforms
     *
     * Copyright (C) 2010 OSCLASS
     *
     * This program is free software: you can redistribute it and/or modify it under the terms
     * of the GNU Affero General Public License as published by the Free Software Foundation,
     * either version 3 of the License, or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     * See the GNU Affero General Public License for more details.
     *
     * You should have received a copy of the GNU Affero General Public
     * License along with this program. If not, see <http://www.gnu.org/licenses/>.
     */

    // Include the autoloader provided in the SDK
    
require_once dirname__FILE__ ) . '/src/autoload.php';

    
// Include required libraries
    
use Facebook\Facebook;
    use 
Facebook\Exceptions\FacebookResponseException;
    use 
Facebook\Exceptions\FacebookSDKException;


    class 
OSCFacebook extends DAO
    
{
        private static 
$instance;
        private static 
$facebook;
        private static 
$user;
        private static 
$loginUrl;
        private static 
$logoutUrl;
        private static 
$user_profile;

        public static function 
newInstance()
        {
            if(!
self::$instance instanceof self) {
                
self::$instance = new self;
            }

            return 
self::$instance;
        }

        public function 
__construct()
        {
            
parent::__construct();
            
$this->setTableName't_facebook_connect' );
            
$this->setPrimaryKey'fk_i_user_id' );
            
$this->setFields( array( 'fk_i_user_id''i_facebook_uid' ) );


            
self::$facebook = new Facebook(array(
                
'app_id'  => 'YOUR APP ID',
                
'app_secret' => 'YOUR APP SECRET',
                
'default_graph_version' => 'v2.10'
            
));

        }

        public function 
init() {

            
// Get redirect login helper
            
$helper self::$facebook->getRedirectLoginHelper();

            
// Try to get access token
            
try {
                if(isset(
$_SESSION['facebook_access_token'])){
                    
$accessToken $_SESSION['facebook_access_token'];
                }else{
                    
$accessToken $helper->getAccessToken();
                }
            } catch(
FacebookResponseException $e) {
                echo 
'Graph returned an error: ' $e->getMessage();
                exit;
            } catch(
FacebookSDKException $e) {
                echo 
'Facebook SDK returned an error: ' $e->getMessage();
                exit;
            }

            if(isset(
$accessToken)){

                if(isset(
$_SESSION['facebook_access_token'])){
                    
self::$facebook->setDefaultAccessToken($_SESSION['facebook_access_token']);
                }else{
                    
// Put short-lived access token in session
                    
$_SESSION['facebook_access_token'] = (string) $accessToken;
                    
                    
// OAuth 2.0 client handler helps to manage access tokens
                    
$oAuth2Client self::$facebook->getOAuth2Client();
                    
                    
// Exchanges a short-lived access token for a long-lived one
                    
$longLivedAccessToken $oAuth2Client->getLongLivedAccessToken($_SESSION['facebook_access_token']);
                    
$_SESSION['facebook_access_token'] = (string) $longLivedAccessToken;
                    
                    
// Set default access token to be used in script
                    
self::$facebook->setDefaultAccessToken($_SESSION['facebook_access_token']);
                }

                
// Redirect the user back to the same page if url has "code" parameter in query string
                
if(isset($_GET['code'])){
                    
header('Location: ./');
                }

                

                
// Getting user facebook profile info
                
try {
                    
$profileRequest self::$facebook->get('/me?fields=name,first_name,last_name,email,link,gender,locale,picture');
                    
self::$user_profile $profileRequest->getGraphNode()->asArray();
                } catch(
FacebookResponseException $e) {
                    echo 
'Graph returned an error: ' $e->getMessage();
                    
self::$facebook->destroySession();
                    
// Redirect user back to app login page
                    
header("Location: ./");
                    exit;
                } catch(
FacebookSDKException $e) {
                    echo 
'Facebook SDK returned an error: ' $e->getMessage();
                    exit;
                }

                
self::$user $this->getUser();

                if ( !
self::$user ) {
                    return 
self::$facebook;
                }

                try {
                    
$this->dao->select$this->getFields() );
                    
$this->dao->from$this->getTableName() );
                    
$this->dao->where'i_facebook_uid'self::$user );

                    
$rs $this->dao->get();

                    if( ( 
$rs !== false ) && ( $rs->numRows() === ) ) {
                        
$fbUser $rs->row();
                        if( 
count($fbUser) > ) {
                            require_once 
osc_lib_path() . 'osclass/UserActions.php';
                            
$uActions = new UserActionsfalse );
                            
$logged   $uActions->bootstrap_login$fbUser['fk_i_user_id'] );

                            switch( 
$logged ) {
                                case 
0osc_add_flash_error_message__'The username doesn\'t exist''facebook' ) );
                                break;
                                case 
1osc_add_flash_error_message__'The user has not been validated yet''facebook' ) );
                                break;
                                case 
2osc_add_flash_error_message__'The user has been suspended''facebook' ) );
                                break;
                            }
                            return 
self::$facebook;
                        }
                    }

                    if(
is_null(self::$user_profile)) {
                        if (isset(
$_SERVER['HTTP_COOKIE'])) {
                            
$cookies explode(';'$_SERVER['HTTP_COOKIE']);
                            foreach (
$cookies as $cookie) {
                                
$parts explode('='$cookie);
                                
$name trim($parts[0]);
                                
setcookie($name''time() - 1000);
                                
setcookie($name''time() - 1000'/');
                            }
                        }

                        
osc_add_flash_error_message(__('Some error occured trying to connect with Facebook.''facebook'));
                        
header'Location: ' osc_register_account_url()  );
                        exit();
                    } else{
                        if( !isset(
self::$user_profile['email']) ) {

                            if (isset(
$_SERVER['HTTP_COOKIE'])) {
                                
$cookies explode(';'$_SERVER['HTTP_COOKIE']);
                                foreach (
$cookies as $cookie) {
                                    
$parts explode('='$cookie);
                                    
$name trim($parts[0]);
                                    
setcookie($name''time() - 1000);
                                    
setcookie($name''time() - 1000'/');
                                }
                            }

                            
osc_add_flash_error_message(__('Some error occured trying to connect with Facebook.''facebook'));
                            
header'Location: ' osc_register_account_url() );
                            exit();
                        }
                    }

                    
$manager User::newInstance();
                    
$oscUser $manager->findByEmailself::$user_profile['email'] );
                    
// exists on our DB, we merge both accounts
                    
if( count($oscUser) > ) {
                        require_once 
osc_lib_path() . 'osclass/UserActions.php';
                        
$uActions = new UserActionsfalse );

                        
$manager->dao->from$this->getTableName() );
                        
$manager->dao->set'fk_i_user_id'$oscUser['pk_i_id'] );
                        
$manager->dao->set'i_facebook_uid'self::$user_profile['id'] );
                        
$manager->dao->insert();
                        
// activate user in case is not activated
                        
$manager->update( array('b_active' => '1'), array('pk_i_id' => $oscUser['pk_i_id']) );
                        
$logged $uActions->bootstrap_login$oscUser['pk_i_id'] );
                        
osc_add_flash_ok_message__"You already have an user with this e-mail address. We've merged your accounts"'facebook' ) );
                    } else {
                        
// Auto-register him
                        
$this->register_userself::$user_profile );
                    }

                    
// redirect to log in
                    
header'Location: ' osc_base_url() );
                    exit;


                } catch (
FacebookApiException $e) {
                    
self::$user null;
                }

                return 
self::$facebook;

            } else {
                
// Get login url
                
if( !osc_is_web_user_logged_in() ) {
                    
self::$loginUrl  $helper->getLoginUrlosc_base_url(), array('scope' => 'email'));
                }
            }
            
        }

        public function 
import$file )
        {
            
$path osc_plugin_resource$file );
            
$sql  file_get_contents$path );

            if( !
$this->dao->importSQL$sql ) ) {
                throw new 
Exception__('Error importing the database structure of the jobboard plugin''jobboard') );
            }
        }

        public function 
uninstall()
        {
            
$this->resetCookies();
            
$this->dao->query'DROP TABLE ' $this->getTableName() );
        }

        public function 
getFacebook()
        {
            return 
self::$facebook;
        }

        public function 
getUser()
        {
            if( 
self::$user == null ) {
                
self::$user self::$user_profile['id'];
            }

            return 
self::$user;
        }

        public function 
getUsername() 
        {
            if( 
self::$user_profile['email'] != null ) {
                
$splusername explode('@'self::$user_profile['email']);
                
$username $splusername[0];
            }
            return 
$username;
        }

        public function 
logoutUrl()
        {
            return 
self::$logoutUrl;
        }

        public function 
loginUrl()
        {
            return 
self::$loginUrl;
        }

        public function 
profile()
        {
            if( 
self::$user_profile == null ) {
                
self::$user_profile self::$facebook->get'/me?fields=name,first_name,last_name,email,link,gender,locale,picture' );
            }

            return 
self::$user_profile;
        }

        private function 
register_user($user)
        {
            
$manager User::newInstance();

            
$input['s_name']      = $user['name'];
            
$input['s_username']  = $this->getUsername();
            
$input['s_email']     = $user['email'];
            
$input['s_password']  = sha1osc_genRandomPassword() );
            
$input['dt_reg_date'] = date'Y-m-d H:i:s' );
            
$input['s_secret']    = osc_genRandomPassword();
            
$input['b_active']    = 1;

            
$email_taken $manager->findByEmail$input['s_email'] );
            if(
$email_taken == null) {
                
$manager->insert$input );
                
$userID $manager->dao->insertedId();

                
$manager->dao->from$this->getTableName() );
                
$manager->dao->set'fk_i_user_id'$userID );
                
$manager->dao->set'i_facebook_uid'$user['id'] );
                
$result $manager->dao->replace();

                if( 
$result == false ) {
                    
// error inserting user
                    
return false;
                }

                
osc_run_hook'user_register_completed'$userID );

                
$userDB $manager->findByPrimaryKey$userID );

                if( 
osc_notify_new_user() ) {
                    
osc_run_hook'hook_email_admin_new_user'$userDB );
                }

                
osc_run_hook('hook_email_user_registration'$userDB);
                
osc_run_hook('validate_user'$userDB);

                
osc_add_flash_ok_messagesprintf__('Your account has been created successfully''facebook' ), osc_page_title() ) );
                return 
true;
            }
        }

        public function 
resetCookies()
        {
            
//self::$facebook->destroySession();
            // Remove access token from session
            
unset($_SESSION['facebook_access_token']);

            
// Remove user data from session
            
unset($_SESSION['userData']);
        }
    }

    
/* file end: ./oc-content/plugins/facebook/OSCFacebook.php */
?>


3. Try

Can you help me with this?
Warning: Cannot modify header information - headers already sent by (output started at /homepages/1/d542639206/htdocs/oc-content/plugins/facebook/OSCFacebook.php:1) in /homepages/1/d542639206/htdocs/oc-includes/osclass/core/Cookie.php on line 97

Warning: Cannot modify header information - headers already sent by (output started at /homepages/1/d542639206/htdocs/oc-content/plugins/facebook/OSCFacebook.php:1) in /homepages/1/d542639206/htdocs/oc-includes/osclass/core/AdminSecBaseModel.php on line 95
Title: Re: Please confirm here - if the FB plugin works
Post by: WEBmods on March 22, 2018, 11:57:36 pm
Hello,

The Facebook Connect app just an official update by osclass team. It should fix your bug.

https://market.osclass.org/plugins/social-networks/free-facebook-connect_18

Regards.
Title: Re: Please confirm here - if the FB plugin works
Post by: rdzdavid on March 23, 2018, 08:09:02 am
Thank you so much!