Skip to content

Instantly share code, notes, and snippets.

@rutgervanwaveren
rutgervanwaveren / silk-map-example.php
Created November 29, 2012 10:30
Silk API examples (PHP)
<?php
//
// This sample script performs a query on world.silkapp.com and outputs the results on a map
// Live example on: http://silktool.com/map-example.php
//
// function to post an http request
function doPost ($url, $payload){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
<!-- bar chart -->
<!-- page structure showing the title (line 7) and subtitle (line 8) -->
<article>
<section class="body">
<div class="layout meta"> <!-- left column -->
<div class="block header text" data-component-uri="http://silkapp.com/component/block/text">
<h1>Title</h1>
<p>Subtitle</p>
</div>
</div>
# get the taglist of a site
$ curl https://api.silkapp.com/v1.4.0/site/uri/yoursite.silkapp.com/taglist
<!-- a tag in Silk using the data-tag-uri attribute -->
John is <a data-tag-uri="http://yoursite.silkapp.com/tag/age">46</a> years old.
<!-- to add a category to a page, use the data-tag-context attribute -->
<!-- this page has as title "John Doe" and it has the category "person" -->
<article data-tag-context="http://yoursite.silkapp.com/tag/person" data-title="John Doe">...</article>
# create new page (or adjust existing page) called 'test'
$ curl https://api.silkapp.com/v1.4.0/site/uri/yoursite.silkapp.com/page/test
-d '<article>...</article>'
-b 'silk_sid=...'
-X PUT
-H 'Content-Type: application/xml'