Created
March 7, 2013 16:14
-
-
Save codingjester/5109193 to your computer and use it in GitHub Desktop.
Extremely basic working PHP script for the /posts route
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
weather the code is working ?