Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Created April 26, 2011 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaindooley/941905 to your computer and use it in GitHub Desktop.
Save iaindooley/941905 to your computer and use it in GitHub Desktop.
Example news.php
<?php
require 'curl_request.class.php';
//update this to point to your install
$base = 'http://iain-workingsoftware-com-au.mockups.decalcms.com';
$url = $base.'/index.php?h=DecalApi';
$api_key = 'qZnSiN).yH4cw(gkhPTEKx>[vsg|&mf199Y5Vi]!e5oOalKp0nW0>=&Yt3>i$=+*';
//formulate the post fields for the request
//we'll look at the options in detail below
$fields = array('api_key' => $api_key,
'dateorder' => 'true',//order the results by date
'desc' => 'true',//put the most recent date first
'list' => '1', //get the first list of pages
'numitems' => '10', //we only want one page per list
'tagged' => 'news',//get only items tagged news
);
//send off the request using the CurlRequest class
$xml = simplexml_load_string(CurlRequest::toUrl($url)
->method(CurlRequest::POST)
->postFields($fields)
->execute());
foreach($xml->page as $p)
//since we'll be inside an iframe, use javascript to set the location of the parent window
echo '<a href="'.$base.$p['url'].'" onclick="window.parent.location=\''.$base.$p['url'].'\'; return false;">'.$p['title'].'<a/><br />'.PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment