Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Vanilla outdoors PHP class

DizCowDizCow New
edited September 2013 in Vanilla 2.0 - 2.8
I was looking for a class that could authenticate me outside the Vanilla forums, since i could not find a class that could do this for me i wrote a new PHP class and would like to share it with the world.

Class info:
http://support.dizcow.com/discussion/3/vanilla-outdoors-class-use-vanilla-login-outside-vanilla/#Item_1

Download class:
http://code.google.com/p/dizcow/downloads/detail?name=vanilla_outdoors_1_0.rar

Hope this can help some of you to use the Vannilla loggin outside the forums.

Sample code:
require_once("./library/class.vanilla.outdoors.php");
    
    $vanilla = new vanilla_outdoors();
    
    if($vanilla->check_login()){
        
        echo '<pre>';
        
            print_r($vanilla->get_user_data()); // This will output an array with all the userdata like username, email etc etc.
            
        echo '</pre>';
    
    }else{
        
        echo 'You are not logged in, please loggin first.';
        
    }

Comments

  • Dr_SommerDr_Sommer Dr. of tender Programing ;) ✭✭
    edited September 2013

    Thank You for this Lines, DizCow.. ;)
    FYI: because i had a little struggle with that:
    If you have the Problem like me, that although youre logged out it still shows as you where logged in (shows your Data), then set your Cookie domain in Config.php!!

    $Configuration['Garden']['Cookie']['Domain'] = '.YourDomain.com';

    that solves th issue.. ;)

  • Dr_SommerDr_Sommer Dr. of tender Programing ;) ✭✭
    edited September 2013

    ugh... sorry... my mistake... ;) everything's fine... :D:D

  • x00x00 MVP
    edited September 2013

    This is a crude method that force load vanillas and clears the output buffer, so most likely you are not meeting the requirement of 2.1

    I a strong believer if you use code like this you must understand what it is actually doing.

    grep is your friend.

  • Dr_SommerDr_Sommer Dr. of tender Programing ;) ✭✭

    Hmm... so is there a "right" (AND EASY) Way to do it? What i momentarily need is the Loged in User ID and the discussionID... certainly more in the future, if i extend my "Event plugin" into a "Calender & Event plugin"... ;)

    The Outdoors plugin is functioning with 2.1B2, where i get the UserID... the Topic ID i have to steel over the URL.... ;)

  • The UserID and DiscussionID of what? What is the context?

    You could use and API.

    grep is your friend.

  • businessdadbusinessdad Stealth contributor MVP

    Am I the only one who interprets the title of this discussion as "Vanilla (training) class to be held outdoors"? :)

  • hgtonighthgtonight ∞ · New Moderator

    @Dr_Sommer http://forum.example.com/profile.json will contain the data for the currently logged in user in Vanilla.

    @businessdad said:
    Am I the only one who interprets the title of this discussion as "Vanilla (training) class to be held outdoors"? :)

    Every time!

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • @businessdad said:
    Am I the only one who interprets the title of this discussion as "Vanilla (training) class to be held outdoors"? :)

    I'll bring snacks. Who's getting the beers?

  • note: there is no such thing as "logged in" in a stateless system, you won't be logged in unless you have a session cookie. The basic api, you would connect by the client, or you can forward the session on.

    grep is your friend.

  • Dr_SommerDr_Sommer Dr. of tender Programing ;) ✭✭

    @Hgtonight: "http://forum.example.com/profile.json" not working... just spits out an error...
    Do i need to download the Vanilla API for that? I tried that, still the same Error (link not found)

  • R_JR_J Ex-Fanboy Munich Admin

    You do not have pretty urls enabled, so you need http://caba.de/CaBaFoRuM/index.php?p=/profile.json

  • Dr_SommerDr_Sommer Dr. of tender Programing ;) ✭✭

    ok, great... thats working... thanx R_j ;)

  • Dr_SommerDr_Sommer Dr. of tender Programing ;) ✭✭

    Ahh... this is making me crazy...
    I am making a REAL Chat for Vanilla with Node.js... of course as always with minimum knowledge... ;))

    Cause PHP will not quite work with Node,js (or JS is better in this context) i need to use the profile.json File with Javascript..

    How can I put the "http://caba.de/CaBaFoRuM/index.php?p=/profile.json" into an Javascript Variable, so that I can read out the Name of the logged in User??

    i tried:

    var json = (function () { var json = null; $.ajax({ 'async': false, 'global': false, 'url': "http://caba.de/CaBaFoRuM/index.php?p=/profile.json", 'dataType': "json", 'success': function (data) { json = data; } }); return json; })();

    and:

    $.getJSON("http://caba.de/CaBaFoRuM/index.php?p=/profile.json", function(data) { alert(data.msg); });

    But nothing is working.... any Ideas? ThanX in advance... ;)

  • @Dr_Sommer make a separate discussion srly

    grep is your friend.

  • There was an error rendering this rich post.

This discussion has been closed.