Search

nickdunn: Yes! Don't use this publicly. Anyone can change the URL and access whatever section they wish. For frontend AJAX, use normal pages and events in the normal way.

Roger that. Would be neat to have that kind of API-access via frontend javascript, but I can see how the security implications preclude that.

No idea. But I've removed my own checks for token, so passing auth-token works now.

Would be neat to have that kind of API-access via frontend javascript

But it's quite easy to create such a frontend API manually using Symphony pages and data sources. I'm not sure how this API might simplify that process for the frontend as you would have to setup restriction and permissions.

This extension and its concept is perfect for authorized backend interactions. It's a developer API.

A first version of this extension had the capability to make some sections public (no authentication required) but I've removed this in the spirit of simplicity. Symphony pages, data sources and events make it really easy to create a frontend API tailored to your precise requirements, so there's little point in this extension duplicating this.

Symphony pages, data sources and events make it really easy to create a frontend API tailored to your precise requirements, so there's little point in this extension duplicating this.

Absolutely. This extension just makes it easy to do on-the-fly requests, but I understand that it is aimed at backend interactions. Might be useful as a quick way to test out datasources while developing, though, and then they could be built "for real" via Pages/Datasources/Events before deploying a solution.

Anyway, carry on, boys :)

Will this be usable with the Members extension? Do Members get auth tokens? Would be cool to have authorised Members get access to an API...

Nope, no plans for this to be more than a pure developer API I'm afraid. The security risk is big.

REST API updated to version 1.1.0 on 28th of March 2011

  • support for PUT and DELETE, if plugins want to implement it
  • the ability to delete an entry (send an HTTP DELETE to the entry's ID URL)
  • CSV for exporting entries (reading entries via GET only, CSV doesn't work for any other plugin or HTTP method)
  • improved the documentation and added example XML responses

@davidhund, would you like to give this a try? This is a fork of the extension that adds support for "normal" Symphony page loading, which hopefully fixes compatibility with the Multilanguage extension. Overwrite the files with these new ones, and be sure to re-Enable the REST API extension from the Extensions list (which registers some delegate subscriptions).

https://github.com/nickdunn/rest_api/tree/frontendpage

I tried a quick test locally, and adding language-code seemed to correctly switch field values :-)

@nickdunn thanks a lot Nick. It does not seem to work.

At first I was mucking around trying to switch branches (to frontendpage) and pulling your changes in a new branch (since I am running Rest Api as a Git submodule). This did not work so finally I just downloaded the files as a zip and had my rest_api folder overwritten. I dis/enabled the extension.

Now when I am trying to access http://site.dev/symphony/api/entries/countries?auth-token=1234ab&language-code=nl I get a blank 'Page not found' page.

I tried looking at the REST API: Entries event but this gives a Fatal Error.

PHP Fatal error: Class 'RESTEntries' not found in /my/path/to/site/extensions/restapi/events/event.restapientries.php on line 24on line 24

Maybe something went wrong with updating the extension (how do you pull from another branch in a git submodule? Just a git checkout -b frontendpage + git pull origin frontendpage did not do much...)

Hrm, how odd. Best thing to do then:

  • remove the folder from /extensions entirely
  • delete the row from the sym_extensions table
  • delete the whole ### START API RULES and ### END API RULES block from .htaccess
  • download the branch again, try the zip
  • install as before

I'm not that good with git, so haven't figured out how to switch branches and submodules and all that. I do almost everything with a GUI!

I tried looking at the REST API: Entries event but this gives a Fatal Error.

Ah yes, you shouldn't attach those to pages. I'll update the README, and try to add some logic to prevent them doing anything untoward if you do manage to add them to a page.

Ah I just found that the .htaccess rule that this extension adds (### START API RULES...) needs to be above ### ADMIN REWRITE. If it appears after then the former takes precedence and API URLs with return 404s.

Nick, those rules do appear above the ### ADMIN rules in my case.

Ffingers crossed it's this: you need to have one page in Symphony with a type of "index" (your Symphony home page). I assumed that all sites will have this, as all sites will have a default home page; but if you're still developing you may not have added this yet.

:) It was that…

Works great, I can filter my multi-language content with the language-code param!

Woop! This is very, very cool, as it now means Symphony can act as a central content store from which you can run remotely-hosted, translated satellite sites. Just using extensions, no custom code.

Glad you got it working. I've got a bit more testing on the "frontendpage" branch of this extension to do, but I'll merge these changes back into the master branch when I'm done.

Very cool indeed.

[…] a central content store from which you can run remotely-hosted, translated satellite sites

… is exactly how I plan/need to use it. Awesomeness abounds…

support for PUT and DELETE, if plugins want to implement it

Now that's really RESTful! Thanks again, Nick :)

Nick, The language filtering is working perfectly with the REST Api fork(!) you created (*this is still a fork right, it's not included in the official Git repo?)

Two things I came across while testing. (This might have to do with general DS issues/misunderstanding on my part but…).

  • In the Api Docs you explain the possibility to filter the entries with a filters[foo]=bar. I could not get this to work. What did work was using filter[foo]=bar (singular!). Strange because I see you clearly use filter**s** in your code...
    • I am trying to pull max 2 random entries from my section, through, the Api but cannot get this to work. sort=rand and order=rand|random does not do this. Can I fetch a couple of (filtered) entries randomly?

You're right, the URL parameter is indeed filter and not filters. filter is the correct term (I get that from the line $filters = $_REQUEST['filter'];) so the docs are wrong in this regard.

Yes, you should be able to achieve this. Something like:

?filter[handle1]=value&filter[handle2]=value&limit=2&order=rand

This will filter two fields, limit the results by two entries, and order them randomly. Remember that the sort querystring parameter is to specify the field on which you wish to sort (ID, date, title etc.), so this should be omitted when choosing a random order. Adding sort=rand would make Symphony look for a field named Rand to sort by, randomly.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details