Jump to content

JSON coding.


sepoto

Recommended Posts

I have this URI that I need to call with PHP:

api.tumblr.com/v2/blog/{base-hostname}/info?api_key={key}

The URI is returning a JSON object I think. My question is how in PHP do I call the URI and store the result. Once the result is stored I think I can use json_decode(): to decode the result. My version of PHP is 5.3 so I should not have to add any extensions for json functionality from what I have read. Does anyone know how the URI is called from PHP?Thank you.

Link to comment
Share on other sites

I have this URI that I need to call with PHP:
api.tumblr.com/v2/blog/{base-hostname}/info?api_key={key}

The URI is returning a JSON object I think. My question is how in PHP do I call the URI and store the result. Once the result is stored I think I can use json_decode(): to decode the result. My version of PHP is 5.3 so I should not have to add any extensions for json functionality from what I have read. Does anyone know how the URI is called from PHP?Thank you.

I gave you an example of using cURL here:http://w3schools.invisionzone.com/index.php?showtopic=38968
Link to comment
Share on other sites

<?php$limit = 20;$blog_name = 'sepoto.tumblr.com';$use_url = "http://api.tumblr.com/v2/blog/sepoto.tumblr.com/posts?api_key=yourapicodehere";$posts = false;$curl = curl_init($use_url);curl_setopt($curl, CURLOPT_HTTPGET, true);curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);$response = curl_exec($curl);curl_close($curl);$response = json_decode($response, true);if($response['meta']['status'] == 200){$posts = $response['response']['posts'];}unset ($response);print_r($posts);?>

Link to comment
Share on other sites

<?php$limit = 20;$blog_name = 'sepoto.tumblr.com';$use_url = "http://api.tumblr.com/v2/blog/sepoto.tumblr.com/posts?api_key=yourapicodehere";$posts = false;$curl = curl_init($use_url);curl_setopt($curl, CURLOPT_HTTPGET, true);curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);$response = curl_exec($curl);curl_close($curl);$response = json_decode($response, true);if($response['meta']['status'] == 200){$posts = $response['response']['posts'];}unset ($response);print_r($posts);?>

so what's the deal? does it work? is it not working? do you make sure to actually put your real api key where I said to make sure your actual API key? what is the output of print_r($posts)?
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...