Issue displaying json feed items using PHP - php

I am very new to json in combination with php and wonder why the following code is not working. My mission is displaying the title items one by one.
<?php
$json_string = file_get_contents("https://www.fiverr.com/gigs/gigs_as_json?host=search&type=single_query&query_string=pet&search_filter=rating&category_id=3&sub_category_id=49&limit=48");
$parsed_json = json_decode($json_string, true);
$parsed_json = $parsed_json['gigs'];
foreach($parsed_json as $key => $value)
{
echo $value['title'] . '<br>';
}
?>
The next issue will by, how would I be able to save the image item called cloud_img_med to my server into /grabbed
Your help would be greatly appreciated.

To answer your question about why this code isn't working:
I tried to set it up myself, and found out that the output fetched by file_get_contents is compressed. You can see that by reading the output in a simple var_dump:
var_dump($json_string);
To fix this, you'll need to use a custom context with no compression:
$context = stream_context_create(
array(
'http' => array(
'method' => "GET",
'header' => "Accept-Encoding: gzip;q=0, compress;q=0\r\n",
)
));
Then pass it as the third parameter:
$json_string = file_get_contents("https://www.fiverr.com/gigs/gigs_as_json?host=search&type=single_query&query_string=pet&search_filter=rating&category_id=3&sub_category_id=49&limit=48", false, $context);
I should do this JSON string readable

The code seems to work fine - I tried it on my local machine.
Running this
<?php
$str = <<<EOT
// JSON here...
EOT;
$parsed_json = json_decode($str, true);
$parsed_json = $parsed_json['gigs'];
foreach($parsed_json as $key => $value)
{
echo $value['title'] . '<br>';
}
?>
Gives me this output
replace the MGM lion with your pet or whoever<br>design creative Animal And Pet Company logo<br>`
Which is sort of what you want? If you're having trouble, maybe file_get_contents isn't allowed on your server and you can't get the JSON. Try hardcoding it into the $str variable like I did, and see if you get what you want.
With regards to saving the image, you can check this answer here: https://stackoverflow.com/a/724449/4396258

I think the problem might be the data you're getting from Fiverr's JSON API. At least in my test, I found it was using gzip encoding to compress the data you're requesting. So you have to uncompress it.
$json_string = file_get_contents("https://www.fiverr.com/gigs/gigs_as_json?host=search&type=single_query&query_string=pet&search_filter=rating&category_id=3&sub_category_id=49&limit=48");
$content = json_decode(gzinflate( substr($json_string,10,-8) ));
$gigs = $content->gigs;
foreach($gigs as $key => $value)
{
echo $value->title . '<br>';
}

Related

Reading simple API returns blank screen?

For some reason I cannot figure out how to fix this online anywhere? I have this simple free chuck norris joke api that I'm simply trying to output the json of, but it wont work? I just get a blank screen?
In the console the network tab says 200 ok and that the headers are valid? What am I doing wrong?
My code:
<?php
header('Content-Type: application/json');
header('X-RapidAPI-Host: matchilling-chuck-norris-jokes-v1.p.rapidapi.com');
header('X-RapidAPI-Key: 341b5c1156msh6827bf7184ef4ddp1c8d09jsnbc52db5d01be');
$str = file_get_contents('https://matchilling-chuck-norris-jokes-v1.p.rapidapi.com/jokes/random');
// decode JSON
$json = json_decode($str, true);
// get the data
print_r($json);
Most likely you want to send those headers...
header prints out the headers to you, locally, where you execute it.
With file_get_contents it will be like this:
<?php
$opts = [
"http" => [
"method" => "GET",
"header" => "Content-Type: application/json\r\n" .
"X-RapidAPI-Host: matchilling-chuck-norris-jokes-v1.p.rapidapi.com\r\n" .
"X-RapidAPI-Key: 341b5c1156msh6827bf7184ef4ddp1c8d09jsnbc52db5d01be\r\n"
]
];
$context = stream_context_create($opts);
$str = file_get_contents('https://matchilling-chuck-norris-jokes-v1.p.rapidapi.com/jokes/random', false, $context);
// decode JSON
$json = json_decode($str, true);
// get the data
print_r($json);
I also kindly suggest switching to curl extension.

Echo specific JSON nodes in PHP

I made a RSS to JSON file
https://www.dannny0117.com/.well-known/api/news2.php
It works, in that it returns the output as JSON from the RSS source. Now, I want to print only a few elements from that with PHP echo.
According to the JSON, I need to grab channel, item, title and guid since those are the things I want to output.
I only need the 1st post title and link, but my code just won't pick it up because I don't fully know how to access the thing.
Here is the code that I'm using that I think should echo but doesn't:
<?php
$url = "https://www.dannny0117.com/.well-known/api/news2.php";
$content = file_get_contents($url);
$json = json_decode($content, true);
$title = $content['channel']['item'][0]['title'];
$link= $content['channel']['item'][0]['guid'];
echo $title , $link;
?>
This is not a problem with encoding or unicode character, the main problem is that my code CAN'T read the items from the JSON needed.
There are 2 mistakes which you made:
1) You have UTF-8 characters in your json string.
2) You have output of json_decode() string in variable $json but you are using $content.
Use the code below.
$url = "https://www.dannny0117.com/.well-known/api/news2.php";
$content = file_get_contents($url);
$enc = mb_detect_encoding($content);
if($enc == 'UTF-8') {
$content = preg_replace('/[^(\x20-\x7F)]*/','', $content);
}
$json = json_decode($content,true);
$title = $json['channel']['item'][0]['title'];
$link = $json['channel']['item'][0]['guid'];
echo "<pre>";
print_r([$title , $link]);
you can check this link here , it about predefined constants, usually when you deal with none latin letters you can have this kind of mess. try use JSON_UNESCAPED_UNICODE
and this will solve your problem.
you can use something like this:
$json_output = json_decode($content, true, JSON_UNESCAPED_UNICODE);
as you said it did not work so would you try to add this :
$options = array('http' => array(
'header' => 'Accept-Charset: UTF-8'
)
); $context = stream_context_create($options);
$url = "https://www.dannny0117.com/.well-known/api/news2.php";
$content= file_get_contents($url, false, $context);
$json = json_decode($content, true,JSON_UNESCAPED_UNICODE);

Failed read content from json using cUrl in PHP

This is my first time using web service. My PHP server get the json data from .net server where it is encoded to base64.
The problem now is, i failed to read each attribute inside the data:
Array ( [JSONDataResult] => {"file":"iVBORw0KGgoAAAANSUhEUgAAALUAAAEZCAYAAADR+mSIAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABhuSURBVHhe7ZiBcuM4smz3\/3\/6PkrPjCgfppBMFWB53DgRx2whs4raMWJ7dv938H8\/KVGdjkR1qrNx+13ehftTU9w889V+vVOHqySq05GoTnU2br\/Lu3B\/aoqbZ77ar3fqcJVEdToS1anOxu13eRfuT01x88xX+\/VOHa6SqE5HojrV2bj9Lu\/C\/akpbp75ar\/eeT2cids\/O6cp6Xzad6zeR1PS+bSfovYfz+vhTNz+2TlNSefTvmP1PpqSzqf9FLX\/eF4PZ+L2z85pSjqf9h2r99GUdD7tp6j9x\/N6OBO3f3ZOU9L5tO9YvY+mpPNpP0XtP57XwwpzJ3E5Wd0n6fyn+93c4eZdTlyfuZOo\/HheDyvMncTlZHWfpPOf7nd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YNT56exEnZ2Mss0f487leNWpklH+KlO9k1F2os5ORtnmj3HncqQXiIy6NRu9d5SdqLOTUbb5Y9y5HOkFqox67j31s+s+UGcno2zzx7hzOd65QKdklD0Y5a+yes58lG02m81ms\/kI6q\/jevYq33+Nb34t6aUeZZvNr6BzqTebX8njkipP6p9P1Nlm82twl\/bVBd4Xe\/NrefdSP9gXe\/MrSS\/1KNtsfgXppX7wONsXerPZbDabTYPRv06cmcpH2QOV1RmVP1BZPWP24NX5g3ezzX+U85f56hdeqZ9H2cnj7E6v4vKT2hu9491s8we48wsddV5dkFfnilFWcTvr53ezzR\/gzi9UXYJTcp6NZpKsorJXc6PPrrv5j+N+oUn+6s+KUVfN3jlTn6snqrf5Q4x+oXd+2bws9BU1Y0\/N3TlTnZOaJXOb\/yCvfqF3z9\/t1c9JtzKr92pu8x\/j8YukJ6PswavzispGcy57xau5V+cnLt9sNpvNZrPZbDabzWaz2Ww2m81M\/ve\/\/wclQxXDBQHQjQAAAABJRU5ErkJggg==","fileSize":"8484","returnCode":"0"} )
There are 3 columns:
file
fileSize
returnCode
I have tried to get data using Object, Array or json but always failed.
//$json = json_decode($data, true); //array
//$json = json_decode($data); //object
//echo $result; //JSONDataResult
Below is one of the FAILED method. The full process coding:
<?php
if (isset($_GET['submit'])) {
$project_code = $_GET['project_code'];
$url = "http://1.2.3.4/to/file/process";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($curl, curlopt_httpheader, array ("Content-type:application/json"));
$result = curl_exec($curl);
curl_close($curl);
$data = file_get_contents($url);
$json = json_decode($data, true); //array
//$json = json_decode($data); //object
//echo $result; //JSONDataResult
//print_r($json);
foreach ($json as $key => $value) {
if (!is_array($value)) {
//always goes here
echo "not array: ".$key . '=>' . $value . '<br/>';
} else {
foreach ($value as $key => $val) {
echo "is array: ".$key . '=>' . $val . '<br/>';
}
}
}
}
?>
Guys help me to read the content. I do not mind using which method as long as i can read each column inside the content. Many-many thank you.
[jangankecamsaya]
Assuming the data you posted in the question is the output of print_r($json);, it is clear that $json is an array that contains only one value (the big JSON) associated to the key JSONDataResult. It basically looks like this:
$json = array('JSONDataResult' => '{"file":"iVBORw0KGgoAAAANSUhEUgAAALUAAAEZCAYAAADR+mSIAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABhuSURBVHhe7ZiBcuM4smz3\/3\/6PkrPjCgfppBMFWB53DgRx2whs4raMWJ7dv938H8\/KVGdjkR1qrNx+13ehftTU9w889V+vVOHqySq05GoTnU2br\/Lu3B\/aoqbZ77ar3fqcJVEdToS1anOxu13eRfuT01x88xX+\/VOHa6SqE5HojrV2bj9Lu\/C\/akpbp75ar\/eeT2cids\/O6cp6Xzad6zeR1PS+bSfovYfz+vhTNz+2TlNSefTvmP1PpqSzqf9FLX\/eF4PZ+L2z85pSjqf9h2r99GUdD7tp6j9x\/N6OBO3f3ZOU9L5tO9YvY+mpPNpP0XtP57XwwpzJ3E5Wd0n6fyn+93c4eZdTlyfuZOo\/HheDyvMncTlZHWfpPOf7ndzh5t3OXF95k6i8uN5PawwdxKXk9V9ks5\/ut\/NHW7e5cT1mTuJyo\/n9bDC3ElcTlb3STr\/6X43d7h5lxPXZ+4kKj+e18MKcydJc0pUZyRRnSr56ZwSl5O07+A+StLcSVR+PK+HFeZOkuaUqM5IojpV8tM5JS4nad\/BfZSkuZOo\/HheDyvMnSTNKVGdkUR1quSnc0pcTtK+g\/soSXMnUfnxvB5WmDtJmlOiOiOJ6lTJT+eUuJykfQf3UZLmTqLy43k9rDB3EpcT1\/90TtjvSlyewn2UqM5IkuZOovLjeT2sMHcSlxPX\/3RO2O9KXJ7CfZSozkiS5k6i8uN5PawwdxKXE9f\/dE7Y70pcnsJ9lKjOSJLmTqLy43k9rDB3EpcT1\/90TtjvSlyewn2UqM5IkuZOovL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aJXOb\/yCvfqF3z9\/t1c9JtzKr92pu8x\/j8YukJ6PswavzispGcy57xau5V+cnLt9sNpvNZrPZbDabzWaz2Ww2m81M\/ve\/\/wclQxXDBQHQjQAAAABJRU5ErkJggg==","fileSize":"8484","returnCode":"0"}');
A call to json_decode($json['JSONDataResult'], TRUE) decodes the big string into an array like this:
array(
'file' => 'iVBORw0KGgoAAAANSUhEUgAAALUAAAEZCAYAAADR+mSIAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABhuSURBVHhe7ZiBcuM4smz3/3/6PkrPjCgfppBMFWB53DgRx2whs4raMWJ7dv938H8/KVGdjkR1qrNx+13ehftTU9w889V+vVOHqySq05GoTnU2br/Lu3B/aoqbZ77ar3fqcJVEdToS1anOxu13eRfuT01x88xX+/VOHa6SqE5HojrV2bj9Lu/C/akpbp75ar/eeT2cids/O6cp6Xzad6zeR1PS+bSfovYfz+vhTNz+2TlNSefTvmP1PpqSzqf9FLX/eF4PZ+L2z85pSjqf9h2r99GUdD7tp6j9x/N6OBO3f3ZOU9L5tO9YvY+mpPNpP0XtP57XwwpzJ3E5Wd0n6fyn+93c4eZdTlyfuZOo/HheDyvMncTlZHWfpPOf7ndzh5t3OXF95k6i8uN5PawwdxKXk9V9ks5/ut/NHW7e5cT1mTuJyo/n9bDC3ElcTlb3STr/6X43d7h5lxPXZ+4kKj+e18MKcydJc0pUZyRRnSr56ZwSl5O07+A+StLcSVR+PK+HFeZOkuaUqM5IojpV8tM5JS4nad/BfZSkuZOo/HheDyvMnSTNKVGdkUR1quSnc0pcTtK+g/soSXMnUfnxvB5WmDtJmlOiOiOJ6lTJT+eUuJykfQf3UZLmTqLy43k9rDB3EpcT1/90TtjvSlyewn2UqM5IkuZOovLjeT2sMHcSlxPX/3RO2O9KXJ7CfZSozkiS5k6i8uN5PawwdxKXE9f/dE7Y70pcnsJ9lKjOSJLmTqLy43k9rDB3EpcT1/90TtjvSlyewn2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ileSize' => 8484,
'returnCode' => 0,
);
The value of file is encoded using base64. The complete code should look like this:
// Decode the JSON
$fileInfo = json_decode($json, TRUE);
// Decode the file content
$content = base64_decode($fileInfo['file']);
// Visually inspect its the decoded file content
print_r($content); // Congratulations, it's a PNG!
// Put the content in a file
file_put_contents('...the file path here...', $content);
// Use getimagesize() to learn about the image type
// an rename the file using the correct termination.
Btw, the value of fileSize is the length of the file field, i.e. the content encoded using base64, not the length of the actual PNG file on disk (as I would expect).
You tried to
$json = json_decode($data[0], true); //array
???
(mind the access on the first field on $data)

Pull JSON API results from URL and display in PHP

I've been trying to do this for a couple of days through trial and error etc, but getting absolutely nowhere. PHP isn't my strong point, but I'm generally comfortable with it that I can learn as I go when I need to do specific things.
What I'm trying to do, is take the API from one platform that is used, and input it into another platform that is used. I can get the data from the API easily enough via a URL, and it runs fine on a different server so I'm pretty sure everything is fine on that side of things.
The issue is, that when I do manage to get it from a URL, it comes out looking quite messy. Nothing I've tried so far will display it as a nice tidy block. Furthermore, I'd like to be able to pull specific data from the result and display just that. The data comes out as follows when visited via the URL (have changed values for privacy etc, but the integrity should remain):
{"Data":[{"DeviceID":"1","DeviceName":"Phone 1","Platform":"Phone OS","Edition":"Deluxe","State":"0","Time":"2016-03-16T13:47:44+01:00"}]}
Essentially, what I'm trying to do is:
Display the data in a block list, as opposed to long lines
Allow selection of a specific device through "Device Name", and then display the information relevant to that device
I've tried the following scripts so far:
1:
<?php
$json = file_get_contents('URLHERE');
$obj = json_decode($json);
echo $obj->DeviceID;
?>
2:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'URLHERE');
$result = curl_exec($ch);
curl_close($ch);
$obj = json_decode($result);
echo $result->DeviceName;
?>
3:
<?php
$url = 'URLHERE';
$obj = json_decode(file_get_contents($url), true);
echo $obj['DeviceID'];
?>
4:
<?php
$url = "URLHERE";
$json = file_get_contents($url);
$json_data = json_decode($json, true);
echo "Device: ". $json_data["DeviceID"];
?>
5:
<?php
$json = file_get_contents('URLHERE');
$encodeJ = utf8_encode($json);
$obj = json_decode($encodeJ);
var_dump($obj-> DeviceID);
?>
The fourth one is the closest I've managed to get to it displaying data using these methods, but rather than any information I just get "Device: NULL"
Any help would be appreciated. Starting to pull my hair out here!
UPDATE:
Have managed to make some progress with the following:
<?php
$data = file_get_contents('URLHERE');
$response = json_decode($data, true);
echo 'Device: ' . $response['Data']['0']['DeviceName'];
echo 'Device: ' . $response['Data']['1']['DeviceName'];
?>
This is displaying the device names from the array for value 0 and 1. So now I need to figure out how to iterate through the array and display each one in sequence, as opposed to hard coding each one.
Your DeviceID is in Data & it's an array so you can't access directly. When you
$data = json_decode('{"Data":[{"DeviceID":"1","DeviceName":"Phone 1","Platform":"Phone OS","Edition":"Deluxe","State":"0","Time":"2016-03-16T13:47:44+01:00"}]}', true);//I am using array so second parameter is true to easily demonstrate
Your structure is
[
"Data" => [
[
"DeviceID" => "1",
"DeviceName" => "Phone 1",
"Platform" => "Phone OS",
"Edition" => "Deluxe",
"State" => "0",
"Time" => "2016-03-16T13:47:44+01:00",
],
],
]
So to get only first DeviceID if you want then
$deviceID = isset($data['Data'][0]['DeviceID']) ? $data['Data'][0]['DeviceID'] : null;
or if you want all the DeviceIDs then
$deviceIds = [];
if (isset($data['Data']) && is_array($data['Data']))
{
foreach ($data['Data'] as $row)
{
if (isset($row['DeviceID']))
{
$deviceIds[] = $row['DeviceID'];
}
}
}
or you can use array_column if your php version is >= 5.5.0 or php 7
$deviceIds = [];
if (isset($data['Data']) && is_array($data['Data']))
{
$deviceIds = array_column($data['Data'], 'DeviceID');
}
To get the data, use:
$json = file_get_contents( $url );
Then get it into an array, as:
$arr = json_decode( $json, TRUE );
To "Display the data in a block list, as opposed to long lines", use:
foreach ( $arr AS $element ) {
foreach ( $element AS $e ) {
echo $e['DeviceName'] . '<br>';
}
}
To "Allow selection of a specific device through "Device Name", and then display the information relevant to that device", use:
$deviceName = "Phone 1"; // depending upon your use case, you'll need to decide how you want to set this variable; it's hard coded here for the sake of example
foreach ( $arr AS $element ) {
foreach ( $element AS $e ) {
if ( $e['DeviceName'] = $deviceName ) {
echo '<pre>';
print_r( $e );
echo '</pre>';
}
}
}
While it's not entirely clear what you mean by "Allow selection of a specific device through "Device Name"", I'm inclined to believe you're looking for a way to let a user select a device from the list of device names. That's not a task you can accomplish with PHP alone. You'll need to build something for the front end in HTML or Javascript that interacts with your PHP on the back end.

Php Curl and Json

My question is I want to get acess my fb friends using curl and decode into json then i want to show only those friends whose name starting with letter a such as aman,adam etc pls help me..Following is my code.
<?php
// create a new cURL resource
$json_url="https://graph.facebook.com/100001513782830/friends?access_token=AAACEdEose0cBAPdK62FSjs4RvA21efqc8ZBKyzAesT5r4VSpu0XScAYDtKrCxk4PmcRBVzE2SLiGvs2d5FeXvZAD72ZCShwge3vk4DQqRAb8vLlm1W3";
$ch = curl_init( $json_url );
// Configuring curl options
/* $options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json')
);
// Setting curl options
curl_setopt_array( $ch );
*/// Getting results
$result = curl_exec($ch); // Getting jSON result string
$obj = json_decode($result, true);
foreach($obj[data] as $p)
{
echo '
Name: '.$p[name][first].'
Age: '.$p[age].'
';
}
You will offcourse try not to hardcode "a" but for this purpose :
foreach($obj[data] as $p){
if(strtolower(substr(trim($p[name][first]),0,1)) == 'a'){
echo 'Name: '.$p[name][first].'Age: '.$p[age];
}
}
Btw, it is not a good idea to post security tokens (in URL) to public places.
Since the name is string, you can simply iterate over that array and filter by name:
$letter = 'A';
foreach($obj['data'] as $p) {
if ($p['name'][0] == $letter) {
// do something with $p
}
}
But there is a little problem with UTF-8 -- this solution (and that one with substr too) will not work on multibyte characters. So you need to use mb_substr instead of plain substr function:
foreach($obj['data'] as $p) {
if(mb_strtolower(mb_substr($p['name'], 0, 1))) == 'Á'){
echo "Name: ", $p['name'], "\n",
"Age: ", $p['age'], "\n";
}
}

Categories