Thread Rating:
  • 17 Vote(s) - 4.35 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MyBB Integrator / MyBB SDK (Version 1.3)
Thanks for the fast response! I am still confused. If I understand correctly adding the "_r" to the print, outputs everything. So it makes sense to use echo or print.

So would change it from this

$data = $MyBBI->getUser(2);
print_r($data);

to this?

$data = $MyBBI->getUser(2);
print ($data);

When I tried the last one it just outputs the text "Array"

How would I call the individual item I want? Am I able to change the data variable to say "$postnum" or something? Or would I add something in here like

getUser(2, postnum)

Thanks for helping me. I wish I new more about PHP. Trying to learn it all Toungue
Reply
$data = $MyBBI->getUser(2);      // 2 Is the number of the user id...
echo $data['user'];

This will give the user name of the user...
Reply
Thank you so much! Works perfect. I am beginning to understand arrays a bit better now.
Reply
Amazing, thanks!
[Image: Screen_shot_2010-12-01_at_18.44.51.png]
Macme - Apple News Site & Forum - Coming Soon!
Reply
I am getting the login success / login failure.

Please help me understand what I am doing wrong.

<?php

define("IN_MYBB", NULL);
require_once "/myBB/global.php";
require_once "class.MyBBIntegrator.php";
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config); 

echo ($MyBBI->isLoggedIn()) ? '<br>MyBBI->isLoggedIn(): You are logged in' : '<br>MyBBI->isLoggedIn(): You are not logged in'; 

$username = "MyUsername";
$password = "MyPassword";

$MyBBI->mybb->input['name']= $username;
$MyBBI->mybb->input['password']= $password;
echo '<br>Attempting to login';
$login_status = $MyBBI->login($MyBBI->mybb->input['name'], $MyBBI->mybb->input['password']);

echo ($login_status == true ? '<br>login_status: You are logged in' : 'login_status: You are not logged in'); 

echo ($MyBBI->isLoggedIn()) ? '<br>MyBBI->isLoggedIn(): You are logged in' : '<br>MyBBI->isLoggedIn(): You are not logged in'; 

?>

Output is:
MyBBI->isLoggedIn(): You are not logged in
Attempting to login
login_status: You are logged in
MyBBI->isLoggedIn(): You are not logged in

Cookie settings:
Cookie Domain - .127.0.0.1
Cookie Path - /
Cookie Prefix - (blank)

Site
Site is /website/
Forum is /website/myBB/
Integrator is in main website directory (/website/class.MyBBIntegrator.php)

Info
Other functions like "$data = $MyBBI->getUser(1);" work fine.

The function "print_r($MyBBI);" prints a whole LOT of information.
EDIT: $MyBBI has the following before and after the login function is executed.
[mybb] => MyBB Object
        (
            [version] => 1.4.11
            [version_code] => 1411
            [cwd] => .
            [input] => Array
                (
                    [name] => MyUsername
                    [password] => MyPassword
                )

It appears to be able to use the integrator class, but the login function refuses to work.

I have also tried (and failed).
$login_status = $MyBBI->login($username, $password);

EDIT2: It seems the integrator is unable to create the mybbuser cookie, it only creates the cookies: sid, mybb[lastactive] and mybb[lastvisit]
Apparently I managed to make it work.

It seems the cookies do not like stuff being printed before they get set.
Reply
(2010-02-18, 03:29 PM)Hermiod Wrote: Apparently I managed to make it work.

It seems the cookies do not like stuff being printed before they get set.

Hmmm, very strange... Never heard of it before!
But good job getting it working!
Reply
Does anyone know how to use the UBBParser of MyBB in your own website?

edit: Got it!
Reply
I got the integrator working fine on my PC, but when I try to use it on my server it does not work.

File testIntegrate.php

/public_html/testIntegrate.php
/public_html/class.MyBBIntegrator.php
/public_html/myBB/

<?php
print("CheckPoint 1<br />");
define("IN_MYBB", NULL);

print("CheckPoint 2<br />");
require_once "myBB/global.php";

print("CheckPoint 3<br />");
require_once "class.MyBBIntegrator.php";
$MyBBI = new MyBBIntegrator($mybb, $db, $cache, $plugins, $lang, $config); 

Browser printout:
CheckPoint 1
CheckPoint 2
The following warnings occurred:
Warning [2] Cannot modify header information - headers already sent by (output started at /home/thor/public_html/testIntegrate.php:2) - Line: 1548 - File: inc/functions.php PHP 5.2.12-2 (Linux)

Checkpoints were added after the issue started to debug where it was happening.

The same page works fine on my computer using xampp, but on the server ...

It never even gets to the integrate class, anything I try it just goes to the login page. Any ideas?

The issue is guests have to have the ability to view the board, if they cant view the board global.php sends you to the login page
Reply
This is a very nice mod but I wish there was more support and development given to it. I tested and it works in the latest version.

I was wondering if it is possible to add a link to the thread in getLatestActiveThreads?

If theres no answer anymore I was wondering if there was a similar version of this around? I'm trying to avoid ready made portals. Sad
Reply
I added my own simple little function which I'm sure can be done far better by someone far more experienced than I, but all I really wanted to grab was the UserID's (other information can be fetched later through other functions).

This is useful for building your own "memberlist" pages.

	/**
	 * Gets all user ID's returned in an array
	 *
	 * @return array
	*/
	function getUserIDs()
	{
		$uids = array();
		$query = $this->db->simple_select("users");
		
		while($users = $this->db->fetch_array($query))
		{
			array_push($uids,$users['uid']);
		}
		
		return $uids;
	}

By the way I was having a lot of issues making this work OUTSIDE the forum directory...until eventually I figured out that my cookies were set to use /forums instead of just /, making it just / fixed all those issues. (Facepalm error, lol)

Also, I noticed getUser() doesn't get custom profile fields (properly), so I wrote a function to get all userfields of a specific user (this is the custom profile fields), here it is along with an example.

The code:
	/**
	 * Gets all userfields of a specific userid
	 *
	 * @return array
	*/
	function getUserFields($user_id = 0)
	{
		$userfields = array();
		if($user_id == 0)
			$user_id = $this->mybb->user['uid'];
			
		$query = $this->db->simple_select("userfields","*","ufid='" . $user_id . "'");
		$userfields = $this->db->fetch_array($query);
		
		return $userfields;
	}

The Example (By default fid3 is gender/sex):
	$userfields = $MyBBI->getUserFields($mybb->user['uid']);

	$gender = $userfields['fid3'];

	echo('You are a ' . $gender);

Hope this helps some people.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)