Get data from API url XML php

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
juulphp
New php-forum User
New php-forum User
Posts: 18
Joined: Tue Jan 24, 2017 5:41 am

Sun Feb 05, 2017 4:34 am

Hello,

I've got the problem to get data from an API url in XML en PHP. This is my code:

Code: Select all

<?php
$enter = $_GET["enter"];
$content = file_get_contents("https://www.omdbapi.com/?s=$enter&r=xml");

$xml = simplexml_load_string($content);

if($xml) {

echo "<h2>" .$xml->title. "</h2>";

 }
else
{
echo "Nothing found. Add the info manualy";
}
?>


The problem is that i got an empty h2 tag on the page. What's gone wrong?

Julian

AdoptiveSolution
New php-forum User
New php-forum User
Posts: 163
Joined: Wed Jun 15, 2016 8:35 am

Sun Feb 05, 2017 1:13 pm

The service is currently not available :

http://www.omdbapi.com/?s=bullitt

http://www.omdbapi.com/

Post Reply