Advertisement:

Author Topic: SMF 2.0 "REST" API  (Read 136986 times)

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,099
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #40 on: September 18, 2013, 02:19:29 PM »
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?
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline chinmay235

  • Semi-Newbie
  • *
  • Posts: 21
Re: SMF 2.0 "REST" API
« Reply #41 on: October 01, 2013, 10:33:24 AM »
Hi i am using

Code: [Select]
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?

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,099
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #42 on: October 01, 2013, 11:14:21 AM »
you make it up
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Makavilli

  • Newbie
  • *
  • Posts: 4
Re: SMF 2.0 "REST" API
« Reply #43 on: October 02, 2013, 09:29:20 AM »
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!  :-\ :-\ :-\

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,099
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #44 on: October 02, 2013, 10:00:25 AM »
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...
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Makavilli

  • Newbie
  • *
  • Posts: 4
Re: SMF 2.0 "REST" API
« Reply #45 on: October 02, 2013, 10:18:30 AM »
I am Learning Man that's why am here ! My Question is only where to put the codes shown above! simple non :)

Offline Sunchaser

  • Semi-Newbie
  • *
  • Posts: 41
Re: SMF 2.0 "REST" API
« Reply #46 on: October 02, 2013, 10:27:13 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

Code: [Select]
$api -> get_user()
the getMethod search for

Code: [Select]
smf_api_get_user
while it should search (accordingly to the last version of smf_2_api.php for:

Code: [Select]
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.




Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,099
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #47 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.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Makavilli

  • Newbie
  • *
  • Posts: 4
Re: SMF 2.0 "REST" API
« Reply #48 on: October 02, 2013, 10:46:23 AM »
what i don't unders is where to insert the following codes

Code: [Select]
require_once('SmfRestClient.php');

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

$api->login_user('andre');

$result = $api->get_userInfo();

And thank you.

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,099
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #49 on: October 02, 2013, 10:51:09 AM »
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...
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.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Sunchaser

  • Semi-Newbie
  • *
  • Posts: 41
Re: SMF 2.0 "REST" API
« Reply #50 on: October 02, 2013, 11:28:43 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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Re: SMF 2.0 "REST" API
« Reply #51 on: October 02, 2013, 11:35:25 AM »
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 :/
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline Sunchaser

  • Semi-Newbie
  • *
  • Posts: 41
Re: SMF 2.0 "REST" API
« Reply #52 on: October 02, 2013, 11:37:38 AM »
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...)...


Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Re: SMF 2.0 "REST" API
« Reply #53 on: October 02, 2013, 11:39:25 AM »
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...
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline Sunchaser

  • Semi-Newbie
  • *
  • Posts: 41
Re: SMF 2.0 "REST" API
« Reply #54 on: October 02, 2013, 11:42:10 AM »
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?

Offline Sunchaser

  • Semi-Newbie
  • *
  • Posts: 41
Re: SMF 2.0 "REST" API
« Reply #55 on: October 02, 2013, 11:42:23 AM »
what i don't unders is where to insert the following codes

Code: [Select]
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:

Code: [Select]
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:

Code: [Select]
<?php 
$rc 
ForumBridge_Model::login ('sunchaser');
?>


Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Re: SMF 2.0 "REST" API
« Reply #56 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)
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Offline Sunchaser

  • Semi-Newbie
  • *
  • Posts: 41
Re: SMF 2.0 "REST" API
« Reply #57 on: October 02, 2013, 11:45:49 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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,035
    • Arantor on GitHub
Re: SMF 2.0 "REST" API
« Reply #58 on: October 02, 2013, 11:50:07 AM »
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)
To assume is to hope that those who came before had the presence of mind and capacity to implement the dreams of those who would come after.

You either die a hero or live long enough to see yourself become the villain. It seems you have chosen which, and now I must do the same.

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,099
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #59 on: October 02, 2013, 11:53:38 AM »
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.