Advertisement:

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

Offline wbros

  • Newbie
  • *
  • Posts: 1
Re: SMF 2.0 "REST" API Bug on create post
« Reply #80 on: April 20, 2016, 10:39:34 AM »
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';

Offline andrejpod

  • Newbie
  • *
  • Posts: 2
Re: SMF 2.0 "REST" API
« Reply #81 on: June 29, 2016, 04:34:33 AM »
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.

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 55,106
  • Gender: Male
    • Kindred-999 on GitHub
Re: SMF 2.0 "REST" API
« Reply #82 on: July 01, 2016, 06:35:18 PM »
Sure.. go ahead and get that started....
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 andrejpod

  • Newbie
  • *
  • Posts: 2
Re: SMF 2.0 "REST" API
« Reply #83 on: July 12, 2016, 08:16:04 AM »
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=a@b.net

is something like this possible?
« Last Edit: July 12, 2016, 08:56:26 AM by andrejpod »

Offline Geekologist

  • Newbie
  • *
  • Posts: 6
Re: SMF 2.0 "REST" API
« Reply #84 on: May 14, 2017, 02:14:03 PM »
$result = $api->send_pm(array("to" => array(1)), "test", "test", 0, array(3), 0);

Code: [Select]
The database value you're trying to insert does not exist: to_members

What am I doing wrong?

Offline Geekologist

  • Newbie
  • *
  • Posts: 6
Re: SMF 2.0 "REST" API
« Reply #85 on: June 18, 2017, 12:14:06 PM »
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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,041
    • Arantor on GitHub
Re: SMF 2.0 "REST" API
« Reply #86 on: June 18, 2017, 12:37:17 PM »
2.0.14 changed how logins work. Not sure how feasible it is to fix.
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 Geekologist

  • Newbie
  • *
  • Posts: 6
Re: SMF 2.0 "REST" API
« Reply #87 on: June 18, 2017, 12:41:45 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

Offline Geekologist

  • Newbie
  • *
  • Posts: 6
Re: SMF 2.0 "REST" API
« Reply #88 on: June 18, 2017, 01:03:08 PM »
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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 68,041
    • Arantor on GitHub
Re: SMF 2.0 "REST" API
« Reply #89 on: June 18, 2017, 01:24:33 PM »
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.)
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 darren.a.roberts

  • Newbie
  • *
  • Posts: 3
Re: SMF 2.0 "REST" API
« Reply #90 on: November 27, 2017, 03:30:47 AM »
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?

Online Kindred

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