Advertisement:

Author Topic: I am not getting their Name?  (Read 1776 times)

lonecrowlab

  • Jr. Member
  • **
  • Posts: 79
I am not getting their Name?
« on: February 09, 2015, 07:13:43 pm »
I have a problem in my facebook plugin. It is not saving the facebook name ending up an empty field in Name section of the database and in the header it will just show "Hi" and no name after that. It was working fine a few months ago. What do I need to modify?  :(

This is my register function found in facebook plugin
note:I did not modify anything in this plugin except for its button style. nothing else.

Code: [Select]
        private function register_user($user)
        {
            $manager = User::newInstance();

            $input['s_name']      = $user['name'];
            $input['s_email']     = $user['email'];
            $input['s_password']  = sha1( osc_genRandomPassword() );
            $input['dt_reg_date'] = date( 'Y-m-d H:i:s' );
            $input['s_secret']    = osc_genRandomPassword();

            $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 );
                }

                if(osc_version()>=310) {
                    $manager->update( array('b_active' => '1', 's_username' => $userID)
                                    ,array('pk_i_id' => $userID) );
                } else {
                        $manager->update( array('b_active' => '1')
                            ,array('pk_i_id' => $userID) );
                }

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

                osc_add_flash_ok_message( sprintf( __('Your account has been created successfully', 'facebook' ), osc_page_title() ) );
                return true;
            }
        }
« Last Edit: February 09, 2015, 07:19:52 pm by lonecrowlab »

lonecrowlab

  • Jr. Member
  • **
  • Posts: 79
Re: I am not getting their Name?
« Reply #1 on: February 11, 2015, 12:22:56 pm »
anyone? :(

frontend

  • Newbie
  • *
  • Posts: 7
Re: I am not getting their Name?
« Reply #2 on: February 11, 2015, 03:18:27 pm »
And its normally worked its code with library , tested with https://github.com/facebook/facebook-php-sdk-v4

<!DOCTYPE html>
<html>
<title>facebook login</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
/* INCLUSION OF LIBRARY FILEs*/
require_once( 'Facebook/FacebookSession.php');
require_once( 'Facebook/FacebookRequest.php' );
require_once( 'Facebook/FacebookResponse.php' );
require_once( 'Facebook/FacebookSDKException.php' );
require_once( 'Facebook/FacebookRequestException.php' );
require_once( 'Facebook/FacebookRedirectLoginHelper.php');
require_once( 'Facebook/FacebookAuthorizationException.php' );
require_once( 'Facebook/GraphObject.php' );
require_once( 'Facebook/GraphUser.php' );
require_once( 'Facebook/GraphSessionInfo.php' );
require_once( 'Facebook/Entities/AccessToken.php');
require_once( 'Facebook/HttpClients/FacebookCurl.php' );
require_once( 'Facebook/HttpClients/FacebookHttpable.php');
require_once( 'Facebook/HttpClients/FacebookCurlHttpClient.php');

/* USE NAMESPACES */

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\GraphUser;
use Facebook\GraphSessionInfo;
use Facebook\HttpClients\FacebookHttpable;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookCurl;

/*PROCESS*/

//1.Stat Session
session_start();

//check if users wants to logout
if(isset($_REQUEST['logout'])){
    unset($_SESSION['fb_token']);
}

//2.Use app id,secret and redirect url
$app_id = 'xxxxxxxxxxxxxxxxxxxxx';
$app_secret = 'xxxxxxxxxxxxxxxxxxxxxxxx';
$redirect_url='http://xxx.net/Login/index.php';

//3.Initialize application, create helper object and get fb sess
FacebookSession::setDefaultApplication($app_id,$app_secret);
$helper = new FacebookRedirectLoginHelper($redirect_url);
$sess = $helper->getSessionFromRedirect();

//check if facebook session exists
if(isset($_SESSION['fb_token'])){
    $sess = new FacebookSession($_SESSION['fb_token']);
}

//logout
$logout = 'http://xxx.net/Login/index.php';

//4. if fb sess exists echo name
if(isset($sess)){
    //store the token in the php session
    $_SESSION['fb_token']=$sess->getToken();
    //create request object,execute and capture response
    $request = new FacebookRequest($sess,'GET','/me');
    // from response get graph object
    $response = $request->execute();
    $graph = $response->getGraphObject(GraphUser::classname());
    // use graph object methods to get user details
    $name = $graph->getName();
    $id = $graph->getId();
    $image = 'https://graph.facebook.com/'.$id.'/picture?width=100';
    $email = $graph->getProperty('email');
    echo "hi $name <br>";
    echo "your email is $email <br><Br>";
    echo "<img src='$image' /><br><br>";
    echo "<a href='".$logout."'><button>Logout</button></a>";
}else{
    //else echo login
    echo '<a href="'.$helper->getLoginUrl(array('email')).'" >Login with facebook</a>';
}

?>
</html>


But need which one integration for php 5.4.x , who make a solutions ? its hard code !

« Last Edit: February 11, 2015, 03:21:07 pm by frontend »

lonecrowlab

  • Jr. Member
  • **
  • Posts: 79
Re: I am not getting their Name?
« Reply #3 on: February 12, 2015, 04:02:12 pm »
Did you already figure it out?

frontend

  • Newbie
  • *
  • Posts: 7
Re: I am not getting their Name?
« Reply #4 on: February 12, 2015, 06:25:27 pm »
Yes i work this code but slog on converting..

amscarth

  • Newbie
  • *
  • Posts: 2
Re: I am not getting their Name?
« Reply #5 on: March 16, 2015, 07:31:31 pm »
I ran into the same problem, when using Facebook Connect with the "Required Fields at Registration" plugins.  Disabling "Required Fields" resolved the user name issue with the FB Connect Plugin.

lonecrowlab

  • Jr. Member
  • **
  • Posts: 79
Re: I am not getting their Name?
« Reply #6 on: March 27, 2015, 01:32:01 pm »
Thanks. Gonna check that out.