philsturgeon / ee2-rest

Integrate RESTful API's into your ExpressionEngine 2.0 website with this Rest module.
http://devot-ee.com/add-ons/rest
34 stars 13 forks source link

Rest

Warning: This is extremely deprecated. This is only here because a few years ago I was working on this and selling it, then I stopped working on it, and stopped selling it. I haven't used EE in f**king ages thanks be, and this is only here so that those who paid for it aren't left in the lurch. You can use it, but heck knows if it works with latest EE versions, and it's built on top of a cURL library I mashed out in 2009 and haven't looked at much since.

Integrate RESTful API’s into your ExpressionEngine 2.0 website with this Rest module. You can list Tweets, search for Digg articles, show off Flickr photographs, search YouTube for videos and interact with any open RESTful API.

Installation

Move the "rest/" folder inside "system/expressionengine/third_party/".

Usage

You can create REST requests in the backend module and reference them with Template Syntax, then loop through the returned response. Everything sent back from the API is converted into a loopable ExpressionEngine array wether its XML, JSON, Serialized data, pure PHP, CSV, RSS and Atom feeds. It will even include XML attributes as well as node values so no data is lost.

<ul>
{exp:rest name="foo”}
<li>{some_value}</li>
{/exp:rest}
</ul>

Rest module can do more than just grab information from predefined requests. You can create REST requests on the fly:

{exp:rest url="http://example.com/” verb="get” format="json” param:foo="bar”}
{some_value}<br/>
{/exp:rest}

Parameters

Parameters can be added even if you call a saved request, it will merge or override params saved in the CP.

Debugging

To debug a request you can add debug="yes” to the tag.

You could use this syntax with other Template Tags and create some very dynamic flexible sites.

Pagination

{exp:rest url="[some url]" format="xml" limit="16" offset="{global:pagination_offset}" paginate="bottom" base="feed,documents,document"}

    <p class="largey"><a href="https://github.com/philsturgeon/ee2-rest/blob/master/{url}" title="{title}">{title}</a><span class="large right">{createDate_mon}/{createDate_day}/{createDate_year}</span></p>

    {paginate}
       <ul class="pagination margin_bottom_04">      
        {previous_page}
            <li><a href="https://github.com/philsturgeon/ee2-rest/blob/master/{pagination_url}" title="Previous" class="arrow-prev pager-element">Previous</a></li>
        {/previous_page}

        {page}
            <li><a href="https://github.com/philsturgeon/ee2-rest/blob/master/{pagination_url}"class="current">{pagination_page_number}</a></li>
        {/page}

        {next_page}
            <li><a href="https://github.com/philsturgeon/ee2-rest/blob/master/{pagination_url}" title="Next" class="arrow-next pager-element">Next</a></li>
        {/next_page}
        </ul>
    {/paginate}

{/exp:rest}