Skip to content

Instantly share code, notes, and snippets.

@cutoffthetop
Created July 24, 2013 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cutoffthetop/6069023 to your computer and use it in GitHub Desktop.
Save cutoffthetop/6069023 to your computer and use it in GitHub Desktop.
Short example on how to create a list of article teasers with the Zeit Online API using PHP.
<?php
$host = "http://api.zeit.de";
$query = "/content?fields=teaser_title,href,teaser_text";
$api_key = "&api_key=PUT_YOUR_API_KEY_HERE";
$response = file_get_contents($host.$query.$api_key);
$result = json_decode($response);
?>
<!DOCTYPE html>
<html>
<body>
<h1>Teaser Example</h1>
<?
foreach($result->matches as $item) {
echo "<h2>".$item->teaser_title."</h2>";
echo "<p>".$item->teaser_text."</p>";
echo "<a href='".$item->href."'>weiter</a>";
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment