Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: Modul für Facebook Login?

    Thomas K.

    • Mitglied
    • Beiträge: 214
    Re: Modul für Facebook Login?
    Antwort #15 am: 04. Oktober 2012, 18:49:44
    ich hab doch oben das prinzip erklärt.
    fb bekommt keine weiteren daten.

    Thomas K.

    • Mitglied
    • Beiträge: 214
    Re: Modul für Facebook Login?
    Antwort #16 am: 05. Oktober 2012, 13:03:18
    So,

    der FB Logout hat Ewigkeiten rumgespackt. Entweder Fehlermeldungen oder einfach nicht ausgeloggt.
    Diese Version benutzt nichtmal die FB Graph Javascript API.
    Nun die Kernversion als einzelne PHP-Datei

    Code: PHP  [Auswählen]
    <?php
    /**
     * Copyright 2011 Facebook, Inc.
     *
     * Licensed under the Apache License, Version 2.0 (the "License"); you may
     * not use this file except in compliance with the License. You may obtain
     * a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     * License for the specific language governing permissions and limitations
     * under the License.
     */


    # pfad zur facebook php api https://github.com/facebook/facebook-php-sdk
    require_once('tk-includes/fb_php_sdk/src/facebook.php');

    function redirect_to( $location = NULL ) {
            if ($location != NULL) {
                    header("Location: {$location}");
                    exit;
            }
    }

    $facebook = new Facebook(array(
                    'appId'  => 'yourappid',
                    'secret' => 'yourappsecret',
    ));


    #logout part has to go into logoff.php later
    if(isset($_GET['action']) and $_GET['action'] == 'logout') {
            session_start();
            $fb_key = 'fbs_'."YOUR_FB_APP_ID";
            setcookie($fb_key, '', time() - 3600, '', '/', '');
            unset($_SESSION['fb_uid']);
            session_destroy();

            //destroy the session
            $facebook->destroySession();
            redirect_to("/test_fb2.php");
    }

    // Create our Application instance (replace this with your appId and secret).


    // Get User ID
    $user = $facebook->getUser();

    // We may or may not have this data based on whether the user is logged in.
    //
    // If we have a $user id here, it means we know the user is logged into
    // Facebook, but we don't know if the access token is valid. An access
    // token is invalid if the user logged out of Facebook.

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

    // Login or logout url will be needed depending on current user state.
    if ($user) {
      $logoutUrl = $facebook->getLogoutUrl(
                    # url wohin redirected wird nach logout.
                    array("next" => "http://localhost:8888/test_fb2.php?action=logout")
                    );
    } else {
      $loginUrl = $facebook->getLoginUrl();
    }


    ?>
    <!doctype html>
    <html xmlns:fb="http://www.facebook.com/2008/fbml">
      <head>
        <title>php-sdk</title>
        <style>
          body {
            font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
          }
          h1 a {
            text-decoration: none;
            color: #3b5998;
          }
          h1 a:hover {
            text-decoration: underline;
          }
        </style>
      </head>
      <body>
        <h1>php-sdk</h1>

        <?php if ($user): ?>
          <a href="<?php echo $logoutUrl; ?>">Logout</a>
        <?php else: ?>
          <div>
            Login using OAuth 2.0 handled by the PHP SDK:
            <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
          </div>
        <?php endif ?>

        <h3>PHP Session</h3>
        <pre><?php print_r($_SESSION); ?></pre>

        <?php if ($user): ?>
          <h3>You</h3>
          <img src="https://graph.facebook.com/<?php echo $user; ?>/picture">

          <h3>Your User Object (/me)</h3>
          <pre><?php print_r($user_profile); ?></pre>
        <?php else: ?>
          <strong><em>You are not Connected.</em></strong>
        <?php endif ?>

      </body>
    </html>

     

    Thomas K.

    • Mitglied
    • Beiträge: 214
    Re: Modul für Facebook Login?
    Antwort #17 am: 05. Oktober 2012, 13:04:02
    So,

    der FB Logout hat Ewigkeiten rumgespackt. Entweder Fehlermeldungen oder einfach nicht ausgeloggt.
    Diese Version benutzt nichtmal die FB Graph Javascript API.
    Nun die Kernversion als einzelne PHP-Datei

    Datei heißt test_fb2.php bei mir!
    Code: PHP  [Auswählen]
    <?php
    /**
     * Copyright 2011 Facebook, Inc.
     *
     * Licensed under the Apache License, Version 2.0 (the "License"); you may
     * not use this file except in compliance with the License. You may obtain
     * a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
     * License for the specific language governing permissions and limitations
     * under the License.
     */


    # pfad zur facebook php api https://github.com/facebook/facebook-php-sdk
    require_once('tk-includes/fb_php_sdk/src/facebook.php');

    function redirect_to( $location = NULL ) {
            if ($location != NULL) {
                    header("Location: {$location}");
                    exit;
            }
    }

    $facebook = new Facebook(array(
                    'appId'  => 'yourappid',
                    'secret' => 'yourappsecret',
    ));


    #logout part has to go into logoff.php later
    if(isset($_GET['action']) and $_GET['action'] == 'logout') {
            session_start();
            $fb_key = 'fbs_'."YOUR_FB_APP_ID";
            setcookie($fb_key, '', time() - 3600, '', '/', '');
            unset($_SESSION['fb_uid']);
            session_destroy();

            //destroy the session
            $facebook->destroySession();
            redirect_to("/test_fb2.php");
    }

    // Create our Application instance (replace this with your appId and secret).


    // Get User ID
    $user = $facebook->getUser();

    // We may or may not have this data based on whether the user is logged in.
    //
    // If we have a $user id here, it means we know the user is logged into
    // Facebook, but we don't know if the access token is valid. An access
    // token is invalid if the user logged out of Facebook.

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

    // Login or logout url will be needed depending on current user state.
    if ($user) {
      $logoutUrl = $facebook->getLogoutUrl(
                    # url wohin redirected wird nach logout.
                    array("next" => "http://localhost:8888/test_fb2.php?action=logout")
                    );
    } else {
      $loginUrl = $facebook->getLoginUrl();
    }


    ?>
    <!doctype html>
    <html xmlns:fb="http://www.facebook.com/2008/fbml">
      <head>
        <title>php-sdk</title>
        <style>
          body {
            font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
          }
          h1 a {
            text-decoration: none;
            color: #3b5998;
          }
          h1 a:hover {
            text-decoration: underline;
          }
        </style>
      </head>
      <body>
        <h1>php-sdk</h1>

        <?php if ($user): ?>
          <a href="<?php echo $logoutUrl; ?>">Logout</a>
        <?php else: ?>
          <div>
            Login using OAuth 2.0 handled by the PHP SDK:
            <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
          </div>
        <?php endif ?>

        <h3>PHP Session</h3>
        <pre><?php print_r($_SESSION); ?></pre>

        <?php if ($user): ?>
          <h3>You</h3>
          <img src="https://graph.facebook.com/<?php echo $user; ?>/picture">

          <h3>Your User Object (/me)</h3>
          <pre><?php print_r($user_profile); ?></pre>
        <?php else: ?>
          <strong><em>You are not Connected.</em></strong>
        <?php endif ?>

      </body>
    </html>

     

    Fritz

    • Mitglied
    • Beiträge: 134
    Re: Modul für Facebook Login?
    Antwort #18 am: 05. Oktober 2012, 13:16:30
    Hatte auch schon mal drüber nachgedacht einen Login mit openID zu realisieren  :nixweiss:

    Georg - SOPO

    • Frisch an Board
    • Beiträge: 54
    • Geschlecht:
    Re: Modul für Facebook Login?
    Antwort #19 am: 08. Oktober 2012, 13:48:33
    Push!

    Ich muss sagen, auch für unseren Webshop wäre eine solche Funktion sehr nützlich zumal die Kunden dann direkt mit Ihre Facebook Account (evtl. uns liken können) sowie sich ganz einfach einloggen bzw. registrieren können ohne Straße, Hausnummer etc. zum 100ten male einzugeben.

    Evtl. erbarmt sich ein gut gelaunter Spezialist hier Info zu geben wo und wie man zu so einer Login Funktion kommen könnte.

    Würde mich freuen über eine Info ob es in die Richtung einen Plan gibt für die Zukunft.

    LG

    Thomas K.

    • Mitglied
    • Beiträge: 214
    Re: Modul für Facebook Login?
    Antwort #20 am: 08. Oktober 2012, 17:21:34
    bei mir läufts inzwischen zu 95%.
    Funktioniert alles, nur wird man zum fb-login noch auf die fb-seite redirected (fremdseite = barriere).
    ich will, dass das alles in einem popup funktioniert.

    werde am ende meinen code hier posten.

    zeolite

    • Fördermitglied
    • Beiträge: 142
    • Geschlecht:
    Re: Modul für Facebook Login?
    Antwort #21 am: 09. Oktober 2012, 16:23:02
     :pro:

    NicoDeluxe

    • Fördermitglied
    • Beiträge: 987
    • Geschlecht:
    Re: Modul für Facebook Login?
    Antwort #22 am: 09. Oktober 2012, 16:38:38
    Ich bin da zweigeteilter Meinung

    Teufel sagt ohoh ne blos nicht ist zu unseriös, Kunden haben Angst um Ihre Daten. Kunden denken vielleicht
    selbst wenn Sie den FB Login nicht nutzen, könnten Daten freigegeben werden, weil ich im FB die selbe Email nutze wie hier um mich zu registrieren

    Engel sagt, ja cool modern und nützlich, Kunden können gleich teilen, liken etc.

    The_Warrior

    • Neu im Forum
    • Beiträge: 1
    Re: Modul für Facebook Login?
    Antwort #23 am: 09. Oktober 2012, 17:05:02
    Oh ja, das würde mich auch interessieren, diese Login-Art.

    Bin schon gespannt wenn's soweit ist, dass man es benutzen  kann.

    Bedanke mich im Voraus bei dir   "Thomas K."

    matz

    • Mitglied
    • Beiträge: 171
    Re: Modul für Facebook Login?
    Antwort #24 am: 11. Oktober 2012, 14:24:56
    Ich finde die Idee super.
    Zumal das sowieso auf den deutschen Markt zukommt.

    Wer sich noch immer dagegen sträubt, wird sich zukünft über lang oder kurz dennoch damit beschäftigen müssen. Denn an Social Networks kommt keiner drumrum. Der deutsche Markt hängt 2 Jahre hinter den USA hinterher - und was sich da abzeichnet, kommt hier mit einer Welle auch an.

    Wie kommst du damit vorran Thomas?

    Thomas K.

    • Mitglied
    • Beiträge: 214
    Re: Modul für Facebook Login?
    Antwort #25 am: 12. Oktober 2012, 11:04:24
    bin grade eine woche im urlaub.
    läuft aber bereits in der 95% version auf purpleleaves.de
    Allerdings nur im Login-Popup (Leiste Oben)

    Und hatte einen blöden smarty-Fehler ausgelöst, durch den die $language Variable nicht gesetzt war.
    Ist noch nicht "marktreif".
    Ich poste meinen Code, wenn ich kommende Woche wieder da bin.

    Grüße

    Thomas K.

    • Mitglied
    • Beiträge: 214
    Re: Modul für Facebook Login?
    Antwort #26 am: 17. Oktober 2012, 21:01:10
    Aeh, mein Fehler.
    Hatten wir doch vorsichtshalber erstmal deaktiviert als ich weg war.
    Die nächsten Tage gibs Updates.

    Das smarty $language Problem war, dass das facebook SDK DREISTERWEISE ein session_start() macht ...
    Warum auch immer überschreibt das in Verbindung mit xtc:m die aktuelle Session immer komplett ...

    Thomas K.

    • Mitglied
    • Beiträge: 214
    Re: Modul für Facebook Login?
    Antwort #27 am: 18. Oktober 2012, 14:17:03
    So.

    Ist nun online und letzte Probleme behoben.
    Bitte um fleißiges testen

    purpleleaves.de

    Thomas K.

    • Mitglied
    • Beiträge: 214
    Re: Modul für Facebook Login?
    Antwort #28 am: 18. Oktober 2012, 14:21:40
    Ansatz:

    FB Javascript SDK benutzen, um Login durchzuführen.
    Das FB PHP-SDK benutzen, um Informationen der Nutzer auszulesen und neue Nutzer anzulegen.

    in der general.js.php:
    Sinnvoll in einem script Block einfügen:

    Code: PHP  [Auswählen]
    /*
     * FB Javascript Login Popup & redirect
     */
     <?php
     
     $page = "http://";
     $page .= $_SERVER['SERVER_NAME'];
     if($_SERVER['SERVER_PORT'] == '8888') {
            $page .= ":".$_SERVER['SERVER_PORT'];
     }
     ?>
    function thFBShortCut() {
            //alert('shortcut');
            FB.login(function(response) {
                    if (response.authResponse) {
                            window.location = '<?php echo $page;?>/fb_login.php?action=fb_login';
                    }
                    /*,publish_stream,publish_actions,offline_access, user_status*/
            }, {scope: 'email,user_about_me,user_hometown,user_interests,user_likes,user_website,user_birthday'});
    }
     
    Füge an gewünschte Loginlinks ein "onclick='thFBShortCut(); return false'" an. Setze Link auf gewünschtes Loginscript

    in der includes/header.php am Ende - benutzt ihr facebook plugins schon, ggf. mehrfach auftauchende Sachen nicht wiederholen:

    Code: PHP  [Auswählen]
    ?>
    <div id="fb-root"></div>
    <?php

    $fb = new fb_api();

    ?>
    <script type="text/javascript">
    window.fbAsyncInit = function() {
            FB.init({
                    appId : '<?php echo $fb->appid; ?>', // App ID
                    /*channelUrl : '', // Channel File*/
                    status : true, // check login status
                    cookie : true, // enable cookies to allow the server to access the session
                    oauth : true, // enable OAuth 2.0
                    xfbml : true // parse XFBML
            });
            // Additional initialization code here
    };
    // Load the SDK Asynchronously
    (function(d){
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
    }(document));

    </script>
     
    Eine Instanz meiner FB-Klasse wird erstellt und die app ID daraus herausgelesen

    matz

    • Mitglied
    • Beiträge: 171
    Re: Modul für Facebook Login?
    Antwort #29 am: 18. Oktober 2012, 14:28:00
    Sieht Prima aus :)
    Läuft es jetzt 100%ig?

    Würde es gern auch in meinem Testsystem mal einrichten wenn ich darf?

    Viele Grüße,
    Matz
    Trade Republic - Provisionsfrei Aktien handeln
    1 Antworten
    1469 Aufrufe
    08. September 2017, 14:18:32 von awids
    1 Antworten
    3706 Aufrufe
    21. Januar 2016, 23:33:59 von Teddy65
    0 Antworten
    1860 Aufrufe
    27. August 2014, 07:17:13 von robertko