Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    iscrizione via facebook

    ciao ragazzi ho un problema con un file chiamato facebook.php, ho scaricato sdk di facebook ma appena mi connetto su index.php mi esce questo errore Fatal error: Cannot redeclare class Facebook in /web/htdocs/www.miosito.it/home/prova/src/facebook.php on line 79

    il problema è l'ultimo in fondo, grazie per l'aiuto

    questo è il codice php

    Codice PHP:
    <?php
    require_once "base_facebook.php";
    /** * Extends the BaseFacebook class with the intent of using * PHP sessions to store user ids and access tokens. */class Facebook extends BaseFacebook{  /**   * Identical to the parent constructor, except that   * we start a PHP session to store the user ID and   * access token if during the course of execution   * we discover them.   *   * @param Array $config the application configuration.   * @see BaseFacebook::__construct in facebook.php   */  public function __construct($config) {    if (!session_id()) {      session_start();    }    parent::__construct($config);  }
      protected static 
    $kSupportedKeys =    array('state''code''access_token''user_id');
      
    /**   * Provides the implementations of the inherited abstract   * methods.  The implementation uses PHP sessions to maintain   * a store for authorization codes, user ids, CSRF states, and   * access tokens.   */  protected function setPersistentData($key$value) {    if (!in_array($keyself::$kSupportedKeys)) {      self::errorLog('Unsupported key passed to setPersistentData.');      return;    }
        
    $session_var_name $this->constructSessionVariableName($key);    $_SESSION[$session_var_name] = $value;  }
      protected function 
    getPersistentData($key$default false) {    if (!in_array($keyself::$kSupportedKeys)) {      self::errorLog('Unsupported key passed to getPersistentData.');      return $default;    }
        
    $session_var_name $this->constructSessionVariableName($key);    return isset($_SESSION[$session_var_name]) ?      $_SESSION[$session_var_name] : $default;  }
      protected function 
    clearPersistentData($key) {    if (!in_array($keyself::$kSupportedKeys)) {      self::errorLog('Unsupported key passed to clearPersistentData.');      return;    }
       
    $session_var_name $this->constructSessionVariableName($key);    unset($_SESSION[$session_var_name]);  }
      protected function 
    clearAllPersistentData() {    foreach (self::$kSupportedKeys as $key) {      $this->clearPersistentData($key);    } }
      protected function 
    constructSessionVariableName($key) {    return implode('_', array('fb',                              $this->getAppId(),                              $key));  }}

  2. #2
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    Quote Originariamente inviata da cardi_simo Visualizza il messaggio
    ciao ragazzi ho un problema con un file chiamato facebook.php, ho scaricato sdk di facebook ma appena mi connetto su index.php mi esce questo errore Fatal error: Cannot redeclare class Facebook in /web/htdocs/www.miosito.it/home/prova/src/facebook.php on line 79


    l'errore mi sembra chiaro ha dichiarato + volte una classe con nome facebook

  3. #3
    se tolgo quelle classi non funziona, comunque ho un altro problema

    ho scaricato l'sdk di facebook ho completato tutto, quando uno si registra tramite facebook sul mio sito può soltanto accedere solo tramite facebook e non dal form del sito, vorrei fare qualche modifica tipo che prende il nome utente ad esempio www.facebook/nome.utente poi anche la password e dovrà essere criptata con md5, ho provato a cambiarlo ma non funziona, qualche aiuto?
    in pratica quando prende la password e il nome utente ecc.. potrà accedere anche su un mio social network che ho appena creato. questo lo salverà nel database chiamato name="password" poi quando faccio accedi tramite facebook ho un altro problema non me lo salva nel database name="email"

    questo file è chiamato logi-facebook.php

    Codice PHP:
    <?php


    require 'facebook/facebook.php';
    require 
    'config/fbconfig.php';
    require 
    'config/functions.php';


    $facebook = new Facebook(array(
                
    'appId' => APP_ID,
                
    'secret' => APP_SECRET,
                ));


    $user $facebook->getUser();


    if (
    $user) {
      try {
        
    // Proceed knowing you have a logged in user who's authenticated.
        
    $user_profile $facebook->api('/me');
      } catch (
    FacebookApiException $e) {
        
    error_log($e);
        
    $user null;
      }

        if (!empty(
    $user_profile )) {
            
    # User info ok? Let's print it (Here we will be adding the login and registering routines)
      
            
    $username $user_profile['name'];
                 
    $uid $user_profile['id'];
             
    $email $user_profile['email'];
            
    $user = new User();
            
    $userdata $user->checkUser($uid'facebook'$username,$email,$twitter_otoken,$twitter_otoken_secret);
            if(!empty(
    $userdata)){
                
    session_start();
                
    $_SESSION['id'] = $userdata['id'];
     
    $_SESSION['oauth_id'] = $uid;


                
    $_SESSION['username'] = $userdata['username'];
                
    $_SESSION['email'] = $email;
                
    $_SESSION['oauth_provider'] = $userdata['oauth_provider'];
                
    header("Location: home.php");
            }
        } else {
            
    # For testing purposes, if there was an error, let's kill the script
            
    die("There was an error.");
        }
    } else {
        
    # There's no active session, let's generate one
        
    $login_url $facebook->getLoginUrl(array( 'scope' => 'email'));
        
    header("Location: " $login_url);
    }
    ?>
    fuctions.php

    Codice PHP:
    <?php
    require 'dbconfig.php';
    class 
    User {
        function 
    checkUser($uid$oauth_provider$username,$email,$twitter_otoken,$twitter_otoken_secret)     {        $query mysql_query("SELECT * FROM `users` WHERE oauth_uid = '$uid' and oauth_provider = '$oauth_provider'") or die(mysql_error());        $result mysql_fetch_array($query);        if (!empty($result)) {            # User is already present        } else {            #user not present. Insert a new Record            $query = mysql_query("INSERT INTO `users` (oauth_provider, oauth_uid, username,email) VALUES ('$oauth_provider', $uid, '$username','$email')") or die(mysql_error());            $query = mysql_query("SELECT * FROM `users` WHERE oauth_uid = '$uid' and oauth_provider = '$oauth_provider'");            $result = mysql_fetch_array($query);            return $result;        }        return $result;    }
        
    }
    ?>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.