Customizing SMF > Portals, Bridges, and Integrations

New tools to help integrating SMF with something else

<< < (4/27) > >>

ankifreeze:
hi I have used your api but it doesn't work.... :(

log out function doesn't work....
Code:

require_once ( 'smf_2_api.php');
smfapi_logout('ankifrerreze@gmail.com');


login function also doesn't work...
Code:


require_once ( 'smf_2_api.php');
smfapi_authenticate('ankifreeze', '123456')

Andre N:
Hi,

For login, use

--- Code: ---smfapi_login($email);

--- End code ---
as authenticate will not log a user in, it's only use is to authenticate a username/password combo

as for logout, it should work flawlessly. If you log in manually and then call the logout function on yourself, does it work?

If you try calling it for random users, it will remove them from the database as being logged, so they won't show as being online anymore, but their cookie will persist so when they actually visit the forum they will still be logged in. If you call logout on the current user, only then will the login cookie be destroyed as well ;)

See if that helps. Otherwise it's possible your cookie settings prevent you from accessing SMF's cookie... let me know :)

ankifreeze:
greatt..it does work now...but it doesn't work if log in manually and then call the logout function from api....I see there are some different function in smf_2_api.php and smf script forum ...is  it safe  using your api? ..btw nice tutorial and script.....thanks very much.... :)

ankifreeze:
I got problem when first time I try log in....Notice: Undefined variable:USER_AGENT in C:\xampp\htdocs\site\forum\smf_2_api.php on line1867 ...I found $_SESSION['USER_AGENT'] is not defined...but after that I try to log in and It works....


and I got problem  when I try logout...I can't logout from mysite ( can't logout if I put logout.php in
--- Code: ---http://localhost/site/logout.php
--- End code ---
(mysite folder) ) but it s works if I put  logout.php in
--- Code: ---http://localhost/site/forum/logout.php
--- End code ---
(forum folder)

my forum place

--- Code: ---http://localhost/site/forum/index.php
--- End code ---
my site place

--- Code: ---http://localhost/site/index.php
--- End code ---

also I  have tried register using API like this...


--- Code: ---require_once ( 'smf_2_api.php');
$reg=array();
$reg['member_name']='frank';
$reg['email']='ankfreeze@gmail.com';
$reg['require']='nothing';
$reg['password']='123456';
$reg['password_check']='123456';
smfapi_registerMember($reg);
--- End code ---


--- Code: ---$reg= array(
'member_name' => 'frank',
'email' => 'ankfreeze@gmail.com',
'require' => 'nothing',
'password' => '123456',
'password_check' => '123456',
);
smfapi_registerMember($reg);


--- End code ---
it  works but I feel something wrong and strange....any suggestion... :(

Andre N:
Hi,

First error, change:

--- Code: ---} elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) {

--- End code ---

to be


--- Code: ---} elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && !empty($modSettings['disableCheckUA'])) {

--- End code ---

If they haven't visited the forum this session variable might not be set.

2. If your logout script is working on path /forum but not / then the problem is with your cookie. You need to make sure the cookie path is set for '/' and not for '/forum'. Do this in SMF admin by enabling subdomain independent cookies. Then delete your cookie, login and try it again.

3. You're doing the registration correctly, and it works... what do you mean you feel something wrong and strange? lol :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version