[FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

Page 1 of 2 12 LastLast
Results 1 to 25 of 30
  1. #1
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Hi today i'm going to show you how to set up facebook SDK PHP.

    Everything past this line is not for people who don't know basic php / there way around a CMS so if you don't know how to code wait until people see this and release it for your CMS.

    Download the SDK from github here (Only download /src)

    https://github.com/facebook/facebook-php-sdk

    Now create a /facebook/API/ directory and place the base_facebook.php + crt file + the facebook.php in there.

    Now create a file in just /facebook/ with the name either index or facebook, whatever you want to point the URL too.

    Open that up and put something in there along the lines of this (you can change this around however you want, this is just a basic login / register function)

    PHP Code:

    <?php

    mysql_connect
    ("localhost","root","MYSQL PASS HERE");
    mysql_select_db("DB NAME HERE");

    require_once(
    "API/facebook.php"); // Change file if you have a different way of including files or want more files

    define('APP_ID''YOUR APP ID'); // APP ID from you app page
    define('APP_SECRET''YOUR APP SECRET'); // APP Secret from your app page

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

    $profile $facebook->api('/me');

    $userq mysql_query('SELECT * FROM users WHERE facebook_id = "'.$profile['id'].'"') or die(mysql_error());
    $users mysql_fetch_array($userq);
    $num mysql_num_rows($userq);

    $fbname "NewUser";

    if(
    $num 0){

    // Login function here or starting session
    // header("location:/redirect");

    } else {

    // Login & Register a user here and redirect to wherever
    // header("location:/redirect");

    }

    ?>
    Here's the HTML code for the button, also change these settings (most are labelled).
    PS - This is if you're using habbos css/js so i dunno if your not..
    Spoiler:

    Code:
    <div id="rpx-login">
                    <div>
    <div id="fb-root" class=" fb_reset"><script async="" src="http://connect.facebook.net/en_US/all.js"></script><div style="position: absolute; top: -10000px; height: 0px; width: 0px;"><div><iframe name="fb_xdm_frame_http" frameborder="0" allowtransparency="true" scrolling="no" aria-hidden="true" title="Facebook Cross Domain Communication Frame" tab-index="-1" style="border: none;" src="http://static.ak.facebook.com/connect/xd_arbiter.php?version=18#channel=f1f5c0edcc&amp;origin=http%3A%2F%2Fhebbo.ca&amp;channel_path=%2Findex%3Ffb_xd_fragment%23xd_sig%3Df1b79d2adc%26"></iframe><iframe name="fb_xdm_frame_https" frameborder="0" allowtransparency="true" scrolling="no" aria-hidden="true" title="Facebook Cross Domain Communication Frame" tab-index="-1" style="border: none;" src="https://s-static.ak.facebook.com/connect/xd_arbiter.php?version=18#channel=f1f5c0edcc&amp;origin=http%3A%2F%2Fhebbo.ca&amp;channel_path=%2Findex%3Ffb_xd_fragment%23xd_sig%3Df1b79d2adc%26"></iframe></div></div><div style="position: absolute; top: -10000px; height: 0px; width: 0px;"><div></div></div></div>
    
    			<script type="text/javascript">
        window.fbAsyncInit = function() {
            Cookie.erase("fbsr_183096284873");
            FB.init({appId: 'APPID', status: true, cookie: true, xfbml: true});
            if (window.habboPageInitQueue) {
                // jquery might not be loaded yet
                habboPageInitQueue.push(function() {
                    $(document).trigger("fbevents:scriptLoaded");
                });
            } else {
                $(document).fire("fbevents:scriptLoaded");
            }
    
        };
        window.assistedLogin = function(FBobject, optresponse) {
            
            Cookie.erase("fbsr_183096284873");
            FBobject.init({appId: 'YOURAPPID', status: true, cookie: true, xfbml: true});
    
            permissions = 'user_birthday,user_about_me,email';
            defaultAction = function(response) {
    
                if (response.authResponse) {
                    fbConnectUrl = "LINK TO YOUR FACEBOOK/INDEX LOGIN";
                    Cookie.erase("fbhb_val_183096284873");
                    Cookie.set("fbhb_val_183096284873", response.authResponse.accessToken);
                    Cookie.erase("fbhb_expr_183096284873");
                    Cookie.set("fbhb_expr_183096284873", response.authResponse.expiresIn);
                    window.location.replace(fbConnectUrl);
                }
            };
    
            if (typeof optresponse == 'undefined')
                FBobject.login(defaultAction, {scope:permissions});
            else
                FBobject.login(optresponse, {scope:permissions});
    
        };
    
        (function() {
            var e = document.createElement('script');
            e.async = true;
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            document.getElementById('fb-root').appendChild(e);
        }());
    </script>
    
    <a class="fb_button fb_button_large" onclick="assistedLogin(FB); return false;">
        <span class="fb_button_text">Login with Facebook</span>
    </a>
                    </div>
    
                    <div>
    
    
    <div id="rpx-signin">
        <a class="rpxnow" onclick="return false;" href="#yourextras?">More ways to login</a>
    </div>                </div>
    
                </div>


    Almost forgot, you need your own facebook app, so i'l show you how!

    Click here to show your current apps and the create an app button.

    Click the "Create new app" button to start.

    Now just type in your basic info..
    Spoiler:




    Now your going to need to edit the Site URL, to your facebook index/login url. (/facebook/index.php or /facebook/facebook.php)
    Spoiler:


    Covered app secret + email.


    Now just copy your APP ID + APP SECRET and put it in the files that require editing (not anything in /api).

    The outcome
    Spoiler:


    A working facebook login!


    Note : Like + Rep to show respect to the creator of the tut

    PS, you need cURL enabled for this to work. If you code PHP you can have a nice choose name function / choose pass aswell. For now the $username variable generates random usernames like User1256 and then they can change there username in-client if your using R63B otherwise code a if($_POST['form'] etc.
    Last edited by JaydenC; 02-03-13 at 11:35 PM. Reason: Extra Information


  2. #2
    Eye Eye Capt'n Spheral is offline
    MemberRank
    May 2010 Join Date
    TumptonshireLocation
    2,488Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Right sir, this is very good and tidy.
    I also found that when you change your username in-client, you cant login anymore x]

    Gonna test this out, and work on it for Uber CMS x] (Me no like Rev)

  3. #3
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by JohnHearfield View Post
    Right sir, this is very good and tidy.
    I also found that when you change your username in-client, you cant login anymore x]

    Gonna test this out, and work on it for Uber CMS x] (Me no like Rev)
    Not sure, i'l do a basic web-based change username script if needed?

    Make sure you look over the main php, cause you need to add your own register/login functions like
    $users->adduser(Jayden,Motto,Look); etc - this wont work btw

  4. #4
    Eye Eye Capt'n Spheral is offline
    MemberRank
    May 2010 Join Date
    TumptonshireLocation
    2,488Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by jaydenn View Post
    Not sure, i'l do a basic web-based change username script if needed?

    Make sure you look over the main php, cause you need to add your own register/login functions like
    $users->adduser(Jayden,Motto,Look); etc - this wont work btw
    Yeah, casn you make a web based change username script then? I have some sort of example in my mind on how to do it, but meh.

    Im looking over the main php and trying to figure it all out, i only know a small amount of php, but just learning x]

  5. #5
    Account Upgraded | Title Enabled! iRetro™ is offline
    MemberRank
    Feb 2010 Join Date
    United KingdomLocation
    558Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Amazing release.

  6. #6
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    deleted this script due to how bad it sucked
    Last edited by JaydenC; 28-02-13 at 10:51 PM.

  7. #7
    Eye Eye Capt'n Spheral is offline
    MemberRank
    May 2010 Join Date
    TumptonshireLocation
    2,488Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by jaydenn View Post
    Hmm, considering that I might just do one quickly for uber

    ok heres ur script

    PHP Code:
    <form method="post" action="">
    New username : <input type="text" name="box"/>
    </form>
    <?php

    if($_POST['box']){
    $username "{username}"// {username} is revCMS, not sure about ubers syntax.
    $safe mysql_real_escape_string($_POST['box']);
    mysql_query("UPDATE users SET username="'.$safe.'" WHERE username="'.$username.'"");
    }else{
    // nothing?
    }

    ?>
    just add that somewhere in ur site

    change the $username="{username}"; to $username="%habboName%"; if ur using uberCMS
    Mm, okay, and the user sytax is %habboname% i think

    Error already x[

    Parse error: syntax error, unexpected ''.$safe.'' (T_CONSTANT_ENCAPSED_STRING) in C:\inetupub\wwwroot\rename.php on line 9

  8. #8
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by JohnHearfield View Post
    Mm, okay, and the user sytax is %habboname% i think

    Error already x[

    Parse error: syntax error, unexpected ''.$safe.'' (T_CONSTANT_ENCAPSED_STRING) in C:\inetupub\wwwroot\rename.php on line 9
    Fixed

  9. #9
    Eye Eye Capt'n Spheral is offline
    MemberRank
    May 2010 Join Date
    TumptonshireLocation
    2,488Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Undefined index: box in C:\inetupub\wwwroot\includes\tpl\new-name.tpl on line 14

  10. #10
    topkek amirite?? Leon is offline
    MemberRank
    May 2009 Join Date
    919Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by JohnHearfield View Post
    Undefined index: box in C:\inetupub\wwwroot\includes\tpl\new-name.tpl on line 14
    Got bored.

    PHP Code:
    <?php
    if(isset($_POST['username'])){
        if(empty(
    $_POST['username']) || $_POST['username'] == "") {
            echo 
    "<b>Oops!</b> Username cannot be empty.";
        } else {
            
    $username "{username}"// {username} is revCMS, not sure about ubers syntax.
            
    $safe mysql_real_escape_string($_POST['username']);
            
            
    $check mysql_result(mysql_query("SELECT COUNT(*) FROM users WHERE username = '" $safe "'"), 0);
            if(
    $check != 0) {
                echo 
    "<b>Oops!</b> This username is already taken.";
            } else {
                
    mysql_query("UPDATE users SET username = '" $safe "' WHERE username = '" $username "'");
                echo 
    "<b>Thank you.</b> Your username has been changed.";
                
                
    // Update the session if needed (I don't know how rev/uber have their sessions.)
            
    }
        }
    }
    ?>

    <form method="post" action="">
    New username: <input type="text" name="username" placeholder="New username"/><br />
    <input type="submit" value="Change username" />
    </form>
    Completely untested.

  11. #11
    ☮TAKU???? seanrom is offline
    MemberRank
    Nov 2009 Join Date
    1,004Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    For the username creation thingy you can use $fbdata['username'] to make it more like them. Plus you should never trust users input, not even facebooks API :p

  12. #12
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by HickDead View Post
    For the username creation thingy you can use $fbdata['username'] to make it more like them. Plus you should never trust users input, not even facebooks API :p
    And you think FACECBOOK wouldn't have a some sort of incredible impossible to beat username safety script? the thing you should be worried about is admin-etc.

    PS : I don't think you can take username/real name anymore because they have a security thing. You can however get there "aboutme" + email i believe. Its all here.

  13. #13
    Account Upgraded | Title Enabled! BoomHotel is offline
    MemberRank
    Oct 2008 Join Date
    In a box.Location
    372Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Good thing if you are using BcStorm is you can give them usernamechange and they are then aloud to change there username once.

  14. #14
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by BoomHotel View Post
    Good thing if you are using BcStorm is you can give them usernamechange and they are then aloud to change there username once.
    yep

    did u get it working?

  15. #15
    Account Upgraded | Title Enabled! BoomHotel is offline
    MemberRank
    Oct 2008 Join Date
    In a box.Location
    372Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by jaydenn View Post
    yep

    did u get it working?
    I haven't tried using this FB script yet might start doing it in a minute then I'll see what I can do.

    I get stuck here?

    https://www.facebook.com/dialog/permissions.request
    Last edited by BoomHotel; 01-03-13 at 02:04 AM.

  16. #16
    The one and only! Hejula is offline
    MemberRank
    Nov 2008 Join Date
    4,128Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by BoomHotel View Post
    Good thing if you are using BcStorm is you can give them usernamechange and they are then aloud to change there username once.
    You don't need an emulator to do that. You can just code the function into the CMS.

  17. #17
    Account Upgraded | Title Enabled! BoomHotel is offline
    MemberRank
    Oct 2008 Join Date
    In a box.Location
    372Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by Hejula View Post
    You don't need an emulator to do that. You can just code the function into the CMS.
    But they will have the option in game to do it which is preferred

  18. #18
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by BoomHotel View Post
    I haven't tried using this FB script yet might start doing it in a minute then I'll see what I can do.

    I get stuck here?

    https://www.facebook.com/dialog/permissions.request

    You might need to add your server IP to the permission in the app settings, whitelist it and it should work

  19. #19
    The one and only! Hejula is offline
    MemberRank
    Nov 2008 Join Date
    4,128Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by BoomHotel View Post
    But they will have the option in game to do it which is preferred
    Make a client overlay then, just like the credits box is on the official hotels. The key is creativity.

  20. #20
    Account Upgraded | Title Enabled! BoomHotel is offline
    MemberRank
    Oct 2008 Join Date
    In a box.Location
    372Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by jaydenn View Post
    You might need to add your server IP to the permission in the app settings, whitelist it and it should work
    Tryed that, still get a blank response.

  21. #21
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Quote Originally Posted by BoomHotel View Post
    Tryed that, still get a blank response.
    Actually there may be a reason behind this, I'll just post my page ASLONG AS I DON'T GET CRITIQUE ON MY CODE this time.

  22. #22
    Account Upgraded | Title Enabled! Harrison is offline
    MemberRank
    Mar 2009 Join Date
    417Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    What a handy release :P thanks for this dude.

  23. #23
    Valued Member iOmvuZ is offline
    MemberRank
    May 2012 Join Date
    104Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Could someone make a noob-friendly tutorial about how to set it up on Revcms?
    OT: Nice release sir

  24. #24
    Account Upgraded | Title Enabled! JaydenC is offline
    MemberRank
    Feb 2012 Join Date
    993Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    Updated thread, you can use my code and it will work ASLONG as you add a login + register function into the commented areas.

    Enjoy!

  25. #25
    Account Upgraded | Title Enabled! ηєwв is offline
    MemberRank
    Jun 2007 Join Date
    United KingdomLocation
    258Posts

    Re: [FB CONNECT] Facebook SDK PHP [All CMS][Not beginner friendly]

    I had something similar on my old CMS. However why would you want people to use their FB for a Habbo retro?

    Also, it allowed people to avoid bans.



Page 1 of 2 12 LastLast

Advertisement