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.

Howw to configure Vanilla jsConnect PHP library to work with ExpressionEngine

Somebody can hel me to configure the jsConnect Client Library for PHP to work with ExpressionEngine 2.x.
In the guide i found this:

<?php
require_once dirname(__FILE__).'/functions.jsconnect.php';

// 1. Get your client ID and secret here. These must match those in your jsConnect settings.
$clientID = "1234";
$secret = "1234";

// 2. Grab the current user from your session management system or database here.
$signedIn = true; // this is just a placeholder

// YOUR CODE HERE.

// 3. Fill in the user information in a way that Vanilla can understand.
$user = array();

if ($signedIn) {
   // CHANGE THESE FOUR LINES.
   $user['uniqueid'] = '123';
   $user['name'] = 'John PHP';
   $user['email'] = 'john.php@anonymous.com';
   $user['photourl'] = '';
}

// 4. Generate the jsConnect string.

// This should be true unless you are testing. 
// You can also use a hash name like md5, sha1 etc which must be the name as the connection settings in Vanilla.
$secure = true; 
WriteJsConnect($user, $_GET, $clientID, $secret, $secure);

When i try to include in EE template, i get error with require_once.

How i can get the logged in user information in

 // 2. Grab the current user from your session management system or database here.
$signedIn = true; // this is just a placeholder

// YOUR CODE HERE.

and then how i can fill the user information in
$user = array();

if ($signedIn) {
   // CHANGE THESE FOUR LINES.
   $user['uniqueid'] = '123';
   $user['name'] = 'John PHP';
   $user['email'] = 'john.php@anonymous.com';
   $user['photourl'] = '';
}

Any kind of hel is appreciated.

Thanks
Alessio

Comments

  • edited April 2013

    Step 1 - Fix the require_once() error

    File functions.jsconnect.php is probably missing. You can get it from https://github.com/vanillaforums/jsConnectPHP.

    Step 2 - Retrieve User information

    This is a question for ExpressionEngine community. You should ask on their forum how to do it.

    Step 3 - Fill in User information

    Once you have the data from step 2, this is trivial. Supposing that you get a User object, you would simply do something like this:

       // Code for illustration purposes only
       $user['uniqueid'] = $UserObj->UserID;
       $user['name'] = $UserObj->Name;
       $user['email'] = $UserObj->Email;
       $user['photourl'] = $UserObj->PhotoURL;
    

    Suggestion

    All the above require knowledge of PHP and the ability to write and debug code. I would strongly advise against copy/pasting code, unless you fully understand what it does. A better option would be hiring somebody who could do it for you, a skilled Developer should not spend more than an hour or two to make it work.

  • Thank you for the answer, i've solved with in the expressionengine stack.
    the solution is to get information by "Session Class" here

    with this code:
    $user['uniqueid'] = $this->EE->session->userdata('member_id');
    $user['name'] = $this->EE->session->userdata('username');
    $user['email'] = $this->EE->session->userdata('email');

    Thank you so much for your help.

Sign In or Register to comment.