FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » Fud API Error
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Fud API Error [message #159820] Sun, 28 June 2009 02:00 Go to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
Guys, Im trying to integrate the API with my project, but it is kinda hard...

First I tried without the GLOBALS and it missed the 'fud_use'. After that I tried to add the globals, but then it just dies without any error.

Do you have any advice?
Re: Fud API Error [message #159823 is a reply to message #159820] Sun, 28 June 2009 03:17 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
after some tries, I got the following errors:

Notice: Undefined index: INCLUDE in /libExt/forum/include/core.inc on line 74

Notice: Undefined index: INCLUDE in /libExt/forum/include/core.inc on line 74

Notice: Undefined index: FUD_OPT_1 in /libExt/forum/include/theme/default/db.inc on line 14

Notice: Undefined index: DBHOST in /libExt/forum/include/theme/default/db.inc on line 16

Notice: Undefined index: DBHOST_USER in /libExt/forum/include/theme/default/db.inc on line 16

Notice: Undefined index: DBHOST_PASSWORD in /libExt/forum/include/theme/default/db.inc on line 16

Notice: Undefined index: DBHOST_DBNAME in /libExt/forum/include/theme/default/db.inc on line 18

Notice: Undefined index: DBHOST_DBNAME in /libExt/forum/include/theme/default/db.inc on line 18

Notice: Undefined index: ERROR_PATH in /libExt/forum/include/core.inc on line 187

Notice: Undefined index: ADMIN_EMAIL in /libExt/forum/include/core.inc on line 194

Re: Fud API Error [message #159826 is a reply to message #159823] Sun, 28 June 2009 06:07 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
We need to see your code. Please post a SMALL(!) test case to illustrate the problem.
Re: Fud API Error [message #159828 is a reply to message #159820] Sun, 28 June 2009 10:40 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
    error_reporting(E_ALL);
    var_dump(321);
    require_once sfConfig::get('app_fudforum_lib_path').'/scripts/fudapi.inc.php';
    var_dump(33);
    fud_add_user(array('login' => $this->getUsername(), 'passwd' => $this->getPassword(), 'email' => 'atualizar', 'name' => $this->getUsername()), array());


the error is BEFORE the 33.

the fudapi was patched to find the globals file.
Re: Fud API Error [message #159829 is a reply to message #159828] Sun, 28 June 2009 11:44 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Here is a working example from the wiki:

<?php
 require_once 'GLOBALS.php';
 require_once 'fudapi.inc.php';
 fud_add_user( array('login'=>'me', 'passwd'=>'pass', 'email'=>'me(at)nowhere(dot)com', 'name'=>'Me'), &$err);
?>

Re: Fud API Error [message #159830 is a reply to message #159820] Sun, 28 June 2009 12:02 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
See, the problem is in the fudapi include.
$GLOBAL doesn't have any of the variables needed.
Once the error is in core.inc it means that the GLOBALS is included, at least with the require in the beginning of fudapi file uncommented suggests it.
Re: Fud API Error [message #159831 is a reply to message #159820] Sun, 28 June 2009 12:04 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
using fudapi without the globals give a 'fud_use' error.
Re: Fud API Error [message #159832 is a reply to message #159831] Sun, 28 June 2009 12:09 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
You most definitely need to include GLOBALS.php, either directly, or via the fudapi.inc.php script - your choice.
Re: Fud API Error [message #159833 is a reply to message #159820] Sun, 28 June 2009 12:21 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
I DID it and had the globals problem that is the reason I've posted here!!!
Re: Fud API Error [message #159834 is a reply to message #159833] Sun, 28 June 2009 12:33 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Does it work if you run the example I've posted?
Re: Fud API Error [message #159835 is a reply to message #159820] Sun, 28 June 2009 12:49 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
At this moment I've uninstalled it, but no, it doesn't work cause I've tested before.
When using 'var_dump(array_keys($GLOBALS))' no fud variable was found...
Re: Fud API Error [message #159836 is a reply to message #159835] Sun, 28 June 2009 12:53 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Bummer, I just tested it on my forum and it worked first time.
Re: Fud API Error [message #159837 is a reply to message #159820] Sun, 28 June 2009 12:55 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
Seem that I'm wasting my time here.
Re: Fud API Error [message #159838 is a reply to message #159837] Sun, 28 June 2009 13:10 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Yes, it does appear to be the case. Anyway, I'll stop replying. Maybe someone else will be able to help you.
Re: Fud API Error [message #159850 is a reply to message #159820] Sun, 28 June 2009 20:15 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
Sorry for later... got really frustrated (sorry the typos) cause it isn't working.
Anyway, restarted trying with a better documented code:
public function postInsert($event) {
 error_reporting(E_ALL);
 var_dump('INCLUDING GLOBALS');
 require_once sfConfig::get('app_fudforum_lib_path').'/scripts/GLOBALS.php';
 var_dump('INCLUDING API');
 require_once sfConfig::get('app_fudforum_lib_path').'/scripts/fudapi.inc.php';
 var_dump('CREATING USER');
 var_dump($this->getUsername());
 var_dump($this->getPassword());
 fud_add_user(array('login' => $this->getUsername(), 'passwd' => $this->getPassword(), 'email' => 'atualizar', 'name' => $this->getUsername()), array());    
 var_dump('DONE!!!');
}


reinstalling now...

Re: Fud API Error [message #159851 is a reply to message #159820] Sun, 28 June 2009 20:20 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
string(17) "INCLUDING GLOBALS"
string(13) "INCLUDING API"


as you see it just dies...

I'll try with the globals in another folder...
Re: Fud API Error [message #159852 is a reply to message #159820] Sun, 28 June 2009 20:31 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
seem that the problem now is related to:

fud_use('db.inc');


looked for it and found a '.t' file, but it doesn't load...
Re: Fud API Error [message #159853 is a reply to message #159820] Sun, 28 June 2009 20:48 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
include_once dirname(__FILE__) . fud_theme . $file;


Patched core.inc with this and solved.
Re: Fud API Error [message #159854 is a reply to message #159820] Sun, 28 June 2009 20:59 Go to previous messageGo to next message
sid.gbf is currently offline  sid.gbf   Brazil
Messages: 13
Registered: June 2009
Karma: 0
Junior Member
but everything else fails cause it doesn't have the $GLOBALS array working.
You guys should use a class with static values to that... using this globals looks kina weird...
Re: Fud API Error [message #160178 is a reply to message #159820] Fri, 31 July 2009 09:40 Go to previous messageGo to next message
mazestar is currently offline  mazestar   Hong Kong
Messages: 2
Registered: July 2009
Karma: 0
Junior Member
Hi all,

I had the same problem too.

After my investigation, the main reason of this bug should be the php $GLOBALS variable is unaccessible within core.inc which included by GLOBALS.php. when fudapi.inc.php run fud_use function, because the $GLOBALS is not created yet, so it throw exception.

On the other hand, the funny thing is forum_login.php works perfectly! Then I knew that there must be different GLOBALS handling between forum_login.php and fudapi.inc.php, and found that forum_login.php uses __fud_login_common function to create $GLOBALS...

Lastly, my final solution is:

protected function myAddUser()
{
    $Root = realpath($_SERVER["DOCUMENT_ROOT"]);
    include_once $Root.'/forum_data/include/GLOBALS.php';
    include_once $Root.'/forum_data/scripts/forum_login.php';
    __fud_login_common(1); // The main point!!
    include_once $Root.'/forum_data/scripts/fudapi.inc.php';

    //use function within fudapi
    fud_add_user($arg, &err);
    .....
}


wasted a whole day to get the solution.... Embarassed
Re: Fud API Error [message #160180 is a reply to message #160178] Fri, 31 July 2009 13:45 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Thanks for sharing your solution!

PS: You may also want to look at the examples at http://cvs.prohost.org/index.php/FUDAPI
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: nntp charset problems
Next Topic: After login, front page links don't work
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 22:24:05 GMT 2024

Total time taken to generate the page: 0.03227 seconds