Customizing SMF > Portals, Bridges, and Integrations

SMF 2.0 "REST" API

<< < (2/15) > >>

ankifreeze:
hi I want to integrate mysite with smf forum in order member in mysite don't need to login twice ... but I got problem.....I using this...
--- Code: ---require_once('SmfRestClient.php');

$secretKey = '123456';
$api = new SmfRestClient($secretKey);

$api->get_userInfo();

$api->authenticate_user('greenhorse', '123456');
--- End code ---
but  it doesn't work?
I think after I using it I don't need login in smf forum anymore.....any suggestion? :(

Andre N:
Hi,

This login doesn't set the login cookie on the user browser, it set's it in curl's cookiejar, and the login is only going to be valid for the current API session. Theoretically you could use curl to login and set the login cookie like jquery does, but I haven't had time to mess with it.
It also won't log the user out, as it is intended to run from a different domain and cross-domain policy won't let you delete the cookie. Again, maybe this can be done with curl.

If you're on the same domain, use the regular API, which will let you login and logout easily.
http://www.simplemachines.org/community/index.php?topic=453008.0
Otherwise I'd recommend examining jquery's smf login method and duplicating that.

ankifreeze:
hi..yes I using forum and mysite in same domain.... 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');


--- End code ---

login function also doesn't work...

--- Code: ---
require_once ( 'smf_2_api.php');
smfapi_authenticate('ankifreeze', '123456')
--- End code ---




Andre N:
hi, I will reply to your usage of the regular API in it's thread ;)

newbieuser202:
Hi,

I've installed a new copy of SMF (v.2.0.2) and used your "REST" api.  I tried the very basic function which is login below is the code and results I received.


--- Code: ---require_once('SmfRestClient.php');

$secretKey = 'sdgefgbdbdvberger4564trgdfgdfvcvv';
$api = new SmfRestClient($secretKey);
$result = $api->login_user('testuser@gmail.com');
print_r($result);

--- End code ---

And the result when i user print_r is

--- Code: ---stdClass Object ( [data] => true [error] => )

--- End code ---

Can you point me where I should check for the error since the code does not log in the user to the SMF forum. 

Thank you,

NB

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version