News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SMF 2.0 "REST" API

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

Previous topic - Next topic

wbros

On SmfRestClient.php have a big bug on create post:

protected function create_post()
    {
        try {
            $this->loadSSI();
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
        global $sourcedir;
        require_once($sourcedir . "/Subs-Post.php");

        $this->msgOptions = unserialize($this->msgOptions);
        $this->topicOptions = unserialize($this->topicOptions);
        $this->posterOptions = unserialize($this->posterOptions);

        if (!isset($topicOptions['board']) || !isset($msgOptions['subject']) || !isset($msgOptions['body'])) {
           $this->data = 'false';
        } else {
            $this->data = createPost($this->msgOptions, $this->topicOptions, $this->posterOptions);
        }
    }
You use $topicOptions, $msgOptions without $this reference. Always is "false".

Please, change this to:

if (!isset($this->topicOptions['board']) || !isset($this->msgOptions['subject']) || !isset($this->msgOptions['body'])) { $this->data = 'false';

andrejpod

Hello,

it would be really nice to present REST api as a connection to arbitrary platform, that is to document the raw REST interface for example to use it in Ror, Java or .Net.

Kindred

Sure.. go ahead and get that started....
Сл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."

andrejpod

#83
Can you please give me a raw example of registering a member through a HTTP post with username, password and email?

So in the form of HTTP get/post on

<smf_forum>/api/register/member?secretkey=foo&user=uname&pass=pwd&[email protected]

is something like this possible?

Geekologist

$result = $api->send_pm(array("to" => array(1)), "test", "test", 0, array(3), 0);

The database value you're trying to insert does not exist: to_members


What am I doing wrong?

Geekologist

Doesn't seem to work with the new 0.14v system, I had it working perfectly with the .13v system.. But now it seems there is some kind of problem with the auth part of system.

It just simple returns the login page on api request, but if I take the request URL and manually run it thru browser it works fine because I'm logged in.

Any idea how to fix?

Arantor

2.0.14 changed how logins work. Not sure how feasible it is to fix.

Geekologist

Quote from: Arantor on June 18, 2017, 12:37:17 PM
2.0.14 changed how logins work. Not sure how feasible it is to fix.

Snap! ..

Oh well, I'll recode my system to do something which doesn't require the API, as I don't there is much chance for the OP to update the API

Geekologist

My external site has access to SMF db so creating a function which does a action in the SMF db isn't a problem.

The only thing I needed the API for was to send an PM to a user, everything else I've been able to code myself, but I do not understand how the PM setup is working, I tried creating a function which sends a PM, but didn't work.. Not sure how it all hangs together.. Anyone able to give me an example maybe?

Arantor

As I said in your other thread, use SMF's function to do it. Plus, it is generally discouraged to talk about the innards of PMs here because people who shouldn't be spying on their users' messages will learn how to. (This has been a rule here for at least 10 years now.)

darren.a.roberts

So I've just upgraded to 2.0.15 and the server API stuff is broken. I call this API from another site (using Java) so it looks like I'm stuffed?

If I read correctly from the thread above there are no plans to continue support going forward?

Kindred

The original author of the api has not been active for a long time...    and the api is not actually official smf code...

So, the api May eventually be updated, but given the fact that the official smf focus is on 2.1 beta/RC/final, it may not be for a long time
Сл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."

Faysal230

I try to show my from recent post on my main site,
my configuration is

require_once('SmfRestClient.php');
$secretKey = 'ZTUDgM9K4EJVWB4dllbyFS58zmn0QVAA';
$api = new SmfRestClient($secretKey);
$result = $api->show_recentPosts();
var_dump($result);

But not get any result only blank page.

Kindred

As the post above you notes... I don't believe that this API works on 2.0.15
Сл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."

adrianvk

Hi, in SMF 2.1.1 not working.

The value of the cookie that it generates is very different from the one that SMF generates if you do the manual login.

Any solution?

Thank you

Kindred

As the above posts indicate -- this RESTful API has not worked in the 2.0.x branch for a long time -- and it most certainly does not work in the 2.1.x branch
Сл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."

adrianvk

I found the solution in case it helps someone:

In smf_2_api.php file, replace line 860:
smfapi_setLoginCookie(60 * $cookieLength, $user_data['id_member'], sha1($user_data['passwd'] . $user_data['password_salt']));
For this:
smfapi_setLoginCookie(60 * $cookieLength, $user_data['id_member'], hash_salt($user_data['passwd'],$user_data['password_salt']));

Advertisement: