We can convert php code how to json format? I may have not accurately PHP coding I am beginner to learn about it because I'm new . I'll integrated into Android application. I also draw pictures about how the information ?
for example, I want to do something like this: http://mikepenz.com/android/unsplash/pictures
<?php
// don't forget to change 'username' to your actual tumblr name
$request = 'http://walltumbler.tumblr.com/api/read/json';
$ci = curl_init($request);
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
$input = curl_exec($ci);
// Tumblr JSON doesn't come in standard form, some str replace needed
$input = str_replace('var tumblr_api_read = ','',$input);
$input = str_replace(';','',$input);
// parameter 'true' is necessary for output as PHP array
$value = json_decode($input, true);
$content = $value['posts'];
// the number of items you want to display
$item = 98988;
// Tumblr provides various photo size, this case will choose the 75x75 square one
$type = 'photo-url-1280';
?>
{
"limit": null,
"offset": 0,
"count": 2442,
"total": 2442,
"data": [
<?php
for ($i=0;$i<=$item;$i++) {
if ($content[$i]['type'] == 'photo') {
echo '
{
"id": '.$i.';
"author": "Paul Jarvis",
"image_src": "' . $content[$i][$type] . '",
"color": "#7F7873",
"date": "2015-01-21 19:20:00",
"modified_date": "2014-09-01 22:36:53",
"width": 2500,
"height": 1667,
"ratio": 1.4997000694275,
"featured": 1,
"temp_id": 1
}';
$string = rtrim($item, ', ');
}
}
?>
]}