Skip to content

Instantly share code, notes, and snippets.

@codingjester
Created March 7, 2013 16:14
Show Gist options
  • Save codingjester/5109193 to your computer and use it in GitHub Desktop.
Save codingjester/5109193 to your computer and use it in GitHub Desktop.
Extremely basic working PHP script for the /posts route
<?php
function get_posts($url, $params) {
$params = http_build_query($params);
$client = curl_init($url . "?" . $params);
curl_setopt($client, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($client, CURLOPT_FAILONERROR, 1);
try {
$content = curl_exec($client);
} catch (Exception $e) {
$content = $e->getMessage();
}
curl_close($client);
return $content;
}
print get_posts(
'http://api.tumblr.com/v2/blog/blogname.tumblr.com/posts',
array(
'api_key' => 'your_api_key',
'offset' => 0
)
);
@vigneshmunisamy
Copy link

weather the code is working ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment