News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

SMF 2.0 "REST" API

Started by Andre N, November 10, 2011, 09:29:31 PM

Previous topic - Next topic

Kindred

Did you bother to read the first post?  (the one with the attachments at the bottom?)

Also, did you consider if you need the REST version or the "normal" version?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

chinmay235

Hi i am using

require_once('forum/SmfRestClient.php');
$secretKey = 'sdgefgbdbdvberger4564trgdfgdfvcvv';
$api = new SmfRestClient($secretKey);
$api->login_user("master");
$result = $api->get_userInfo();
var_dump($result);


Please tell me where i get my secrateKey?

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Makavilli

Hello guys could please help me I have downloaded both files and put them where its required but i don't understand what it's meant by: Now you are ready to call the API. You do this by first including the file SmfRestClient.php ....
where should I insert the codes please?? which files??
please I don't know PHP language!  :-\ :-\ :-\

Kindred

Makavilli,
No offense, but if you don't know what you are doing with php, then you really have no business using an API that requires you to know how to code...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Makavilli

I am Learning Man that's why am here ! My Question is only where to put the codes shown above! simple non :)

Sunchaser

Quote from: Sunchaser on July 31, 2012, 11:43:31 AM
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

$api -> get_user()

the getMethod search for

smf_api_get_user

while it should search (accordingly to the last version of smf_2_api.php for:

smfapi_getUserData

I would like to know if someone has a version of SmfRestServer.php fixed.

Thanks

Hi, some time ago i posted this bug. Has a new version of the REST api been released and i need to try to replicate the bug with the new version or there is a place when i can submit this bug and it will be fixed?

thanks.




Kindred

Sunchaser,
Since the author has not been active since July 24 - no... there has been no update to the existing API.

Makavilli,
Again, no offense meant, but APIs like this are not really intended for people who are trying to learn.  By all means, try things out, but there are much better ways to learn php coding and to become familiar with it than by jumping into a script whose only purpose is to connect other scripts.
and when you ask a question, you need to be clear.  You say "...where to put the codes shown above..."  What codes? Sown above, where? there are a fair number of responses in this thread already and it's not clear what you are referring to.

Additionally, this is for the REST version of the API.  If you don't know what REST is, there is a good chance that you should not be using this version, but should be using the standard version of the API instead.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Makavilli

what i don't unders is where to insert the following codes


require_once('SmfRestClient.php');

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

$api->login_user('andre');

$result = $api->get_userInfo();


And thank you.

Kindred

well, you would probably never put them in a block like that...

The first post pretty clearly explains where they need to go  --- in different places withing the script that is calling the API functions.

this is what I mean about knowing what you are doing.   Andre's description and instructions assumes that you alreyad know how php scripts are formed and know where you would need to add the links to the API functions in your bridge or other script.


and again...
Quote from: Kindred on October 02, 2013, 10:39:36 AM
Additionally, this is for the REST version of the API.  If you don't know what REST is, there is a good chance that you should not be using this version, but should be using the standard version of the API instead.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Sunchaser

Quote from: Kindred on October 02, 2013, 10:39:36 AM
Sunchaser,
Since the author has not been active since July 24 - no... there has been no update to the existing API.

Makavilli,
Again, no offense meant, but APIs like this are not really intended for people who are trying to learn.  By all means, try things out, but there are much better ways to learn php coding and to become familiar with it than by jumping into a script whose only purpose is to connect other scripts.
and when you ask a question, you need to be clear.  You say "...where to put the codes shown above..."  What codes? Sown above, where? there are a fair number of responses in this thread already and it's not clear what you are referring to.

Additionally, this is for the REST version of the API.  If you don't know what REST is, there is a good chance that you should not be using this version, but should be using the standard version of the API instead.

Can this API then be added to a respository so we can branch and fix things?

Arantor

That's going to raise an interesting dilemma. Should the author do it or should SMF's dev team take it over and maintain it? The problem is that we're a little short on resources to be expanding what we already support, especially as to be honest I haven't even looked at the API yet :/

Sunchaser

I have a webgame that i need to integrate with a smf forum. Either i make the rest api working or i switch to another forum platform, and i would prefer to make the REST api working.

I think at least the bugs should be fixed (provided that i discovered a bug...)...


Arantor

That's fine, and publishing the fixes here would be a great start. That doesn't change anything I pointed out though; whose responsibility is it to maintain the API?

We didn't originate it and right now we don't have the resources to maintain it on top of trying to get SMF 2.1 out and plan for SMF 3.0...

Sunchaser

I think a rest API is strategic for your platform, you should take care of it and mantain it (bug fixing). This, if you don't have any other API... Have you an official API to integrate other applications?

Sunchaser

Quote from: Makavilli on October 02, 2013, 10:46:23 AM
what i don't unders is where to insert the following codes


require_once('SmfRestClient.php');

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

$api->login_user('andre');

$result = $api->get_userInfo();


And thank you.

Hello, You should put that block in PHP script/class where you want to use it. You can create a ForumBridge class and then add there write for example a method called login and other wrappers.


For example, I have a webgame and i want that when a uset logins in the game he automatically logs in the forum.
I can create the class ForumBridge and the login method:

class ForumBridge_Model {

const SECURITYKEY = 'rewrwerwerwerwrrwr';

/**
* autentica l' utente nel forum
* @param: char oggetto utente
* @return: none
*/

function login( $user )
{
require_once('application/libraries/vendors/smf/SmfRestClient.php');
$api = new SmfRestClient(self::SECURITYKEY);

$rc = $api->login_user( $user -> username );
//var_dump( $rc ); exit;
$result = $api -> get_userInfo();
//var_dump( $result ); exit;
        return $result;
}

...



Then in another script i can call the wrapper:


<?php 
$rc 
ForumBridge_Model::login ('sunchaser');
?>



Arantor

Hm, you could just call SSI.php which will do the login thing for you... and if you really wanted to go nuts you could build it on top of SMF for a single entirely integrated set up without even having it be outside the system, including having it deal with things like SQL injection for you too ;)

Having a REST API is certainly not the only way to do it, there is a non REST API plus SSI (which isn't quite what you want)

Sunchaser

Quote from: Arantor on October 02, 2013, 11:44:15 AM
Hm, you could just call SSI.php which will do the login thing for you... and if you really wanted to go nuts you could build it on top of SMF for a single entirely integrated set up without even having it be outside the system, including having it deal with things like SQL injection for you too ;)

Having a REST API is certainly not the only way to do it, there is a non REST API plus SSI (which isn't quite what you want)

ehm, where i can find these APIS? i could not find them... i would like to check them.

Arantor

Well... the other API is even in the sticky topics in this board, SSI is bundled with SMF itself and building it as an extension to SMF directly, well there's no 'separate API' for that (fairly obviously)

Kindred

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: