Customizing SMF > Portals, Bridges, and Integrations
SMF 2.0 "REST" API
Andre N:
Hi,
There was no error; that is the correct output. The user is logged in through the API only, ie. the cookie is set on the server for the API to use for the duration of the session. The cookie isn't set locally which means if you browse to your forum the user won't be logged in because the cookie isn't set locally.
If you try the other functions you'll see the user is logged in according to the API and you'll be able to access their data, edit, and do whatever you like. Because of cross-domain limitations you won't be able to set login cookie (or delete it, logout) for a user.
If you are on the same domain I recommend you use this version of the API which does not have this limitation and is easier to use as it's only one script:
http://www.simplemachines.org/community/index.php?topic=453008.0
If that is not an option, you might be able to trick SMF into setting the cookie (or deleting it) locally by using cURL to send the login information to your SMF login address. That is the method used by JFusion and seems like it would work , however I haven't had any success doing it yet.
The idea would be to take your SMF login location www.yourforum.com/index.php?action=login2
and cURL the post data, username and password to it and the cookie should be set by SMF.
It would be a nice feature to have and I'll play with it when I get a chance, but if you have any success please post back :)
bidulemachin:
Hi,
I have noticed there was a little bug (well in my version).
in SmfRestServer, in the getMethod(), the method was including the first slash, so it was trying to call "_" and then the actual method. So "_authenticate_user" for example.
I changed the code to be that to make it work:
--- Code: ---
$method = str_replace('/', '_', $parts[0]);
if(substr($method, 0 ,1) == '_')
$method = substr($method, 1, strlen($method));
$this->method = $method;
--- End code ---
Sunchaser:
Hi, i am trying to integrate a game with the SMF forum v 2.0.2 using the REST API.
I think the function getMethod() is broken, as it tries to search for the wrong method.
Example, if i call
--- Code: ---$api -> get_user()
--- End code ---
the getMethod search for
--- Code: ---smf_api_get_user
--- End code ---
while it should search (accordingly to the last version of smf_2_api.php for:
--- Code: ---smfapi_getUserData
--- End code ---
I would like to know if someone has a version of SmfRestServer.php fixed.
Thanks
Sunchaser:
up?
garycarr:
I am trying to setup this API and I am unclear on how the api talks to the SMF installation. In the instructions above I see no way to tell the Rest api where to find SMF and how to connect to it.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version