Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I find out about Apple lookup API and wanted to try something.
JSON: http://itunes.apple.com/lookup?id=443904275
It's only read resultCount, I can't read other data for example app name:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$json = file_get_contents('http://itunes.apple.com/lookup?id=443904275');
$data = json_decode($json,true);
$appname = $data['artistName'];
echo "<pre>";
echo ($appname);
exit;
?>
You need to understand the structure of the object. What you need is:
$appname = $data['results'][0]['artistName'];
Looks like you need to use $data['results'][0]['artistName']
...assuming $data['resultCount'] == 1.
You can always put http://itunes.apple.com/lookup?id=443904275 in your browser to see exactly what you're PHP is working with.
(Edit: what Jonathan said...)
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
i want to echo massages id but i getting 'Warning: Attempt to read property' error
This is my code
<?php
$result ='{"num":1,"message":{"cont":"test"},"messages":[{"id":"123","rct":999}],"status":"success"}';
$obj = json_decode($result);
echo $obj->messages->id;
?>
You have to use like below because messages is also an array.
$result ='{"num":1,"message":{"cont":"test"},"messages":[{"id":"123","rct":999}],"status":"success"}';
$obj = json_decode($result,true);
echo $obj['messages'][0]['id'];
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Does anybody know where I can find a list of all PHP functions? Preferably in an XML file?
The PHP function list is documented on the PHP.net web site however skimming the data off there seems pointless, and I need to know crucial information like return value and parameter type.
What I am trying to do is populate an iPhone application with the list of PHP functions, their return values and their parameter lists. The application then asks questions and expects correct answers.
All help greatly appreciated.
How about this?
<?php
$arr = get_defined_functions()["internal"];
$xml = '<?xml version="1.0"?><root>';
foreach( $arr as $key => $value ){
$xml .= '<function>' . $value . '</function>' . "\r\n";
}
$xml .= '</root>';
echo $xml;
?>
You can write a PHP script that calls get_defined_functions() and use for example PHP's XMLWriter to write the results to an XML file.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I wrote a program that uses an ISBN to query Amazon for that ISBN's price, and returns the following result:
5cb66919-8a8d-4c13-9175-790f0476508d0.0401580000000000TrueISBN9780340979266OffersAllAll0340979267809USD$8.09688USD$6.88598USD$5.98241010000
I need to format this so that I have the price information in a format that would be understandable to a human.
How can I do this?
Use this way..
<?php
$s = '5cb66919-8a8d-4c13-9175-790f0476508d0.0401580000000000TrueISBN9780340979266OffersAllAll0340979267809USD$8.09688USD$6.88598USD$5.982410100000';
$p = explode('USD',$s);
echo "<pre>";
print_r($p);
echo "</pre>";
?>
function returnPrice($response){
$prices = explode('USD',$response);
unset($prices[0]);
return $prices;
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a host of files that generate link like this for hosted files:
http://endertec.com.br/hf/see-img.php?img=http://www.endertec.com.br/hf/do.php?imgf=Fav2.png
But when I see link like this on Facebook, it looks like this:
http://endertec.com.br/hf/see-img.php?img=http%3A%2F%2Fwww.endertec.com.br%2Fhf%2Fdo.php%3Fimgf%3Fav2.png
So I researched ways to convert it, and got the following code:
<?php
$str = 'http://www.endertec.com.br'.$_SERVER['REQUEST_URI'];
$src = str_replace('see-img.php?img=' , '' ,stristr($str , 'see-img.php?img='));
string rawurldecode ( string $src )
echo '<img src="'.$src.'"/>';
?>
But for some reason it does not work, does anyone know how it might work?
You need to store your rawurldecode in something.. try something like this:
$decoded_src = rawurldecode($src);
echo '<img src="'.$decoded_src.'" />';
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Hi i am trying to get video title from dailymotion videos.
$imgid = $video_cek["embed"]; //this is dailymotion id (ex. xint71)
$hash = unserialize(file_get_contents("http://www.dailymotion.com/services/oembed?
format=json&url=http://www.dailymotion.com/embed/video/$imgid"));
$video_cek['baslik']=$hash[0]['title'];
I cant find where is the problem.Thanks
The problem is you are returning JSON Format but trying to unserialize that, this should work:
$imgid = $video_cek["embed"];
$hash = json_decode(file_get_contents("http://www.dailymotion.com/services/oembed?format=json&url=http://www.dailymotion.com/embed/video/$imgid"), true);
$video_cek['baslik']= $hash['title'];
you get a json response, so use json_decode function to Takes a JSON encoded string and converts it into a PHP variable.
like:
$array = json_decode($hash, true);
echo $array['title'];
or
$array = json_decode($hash);
echo $array->title;