it seems like the Json Dataset $data is retrieved, however, it cannot be parsed correctly. Can someone help?
Thanks in advance!
if (extension_loaded('curl'))
{
$headers = array(
'Accept: application/json',
);
$apikey = '###';
$query = ('Iron+Man+1');
$url = 'https://api.themoviedb.org/3/search/movie?api_key' . $apikey . '&query=' . $query;
$session = curl_init();
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt($session, CURLOPT_URL,$url);
curl_setopt($session, CURLOPT_HTTPHEADER, $headers);
curl_setopt($session, CURLOPT_HEADER, 1);
$data = curl_exec($session);
if ($data === NULL) die ('result sets are empty');
$header_size = curl_getinfo($session, CURLINFO_HEADER_SIZE);
$header = substr($data, 0, $header_size);
$body = substr($data, $header_size);
$error_number = curl_errno($session);
$error_message = curl_error($session);
curl_close($session);
}
else
{
throw new TMDbException('CURL-extension not loaded');
}
$results = json_decode($body, true);
if ($results === NULL) die('Error parsing json');
$moviesRelease = $results➞release_date;
فیلم و نمایش تلویزیونی را نمیتوانید پیدا کنید؟ به سیستم وارد شوید تا آن را ایجاد کنید.
آیا میخواهید به این مورد امتیاز دهید یا به فهرست اضافه کنید؟
عضو نیستید؟
پاسخ توسط Travis Bell
در تاریخ ژانویه 4, 2014 ساعت 10:25 ق.ض
Hi vanessaLing,
First, this is PHP right? It might be helpful to add PHP to the subject line for any PHP developers out there.
Second, have you taken a look at any of the PHP libraries for some ideas as to how they do it? I'm not a PHP dev so I am afraid I am not much help.
پاسخ توسط Karl Dietz
در تاریخ ژانویه 5, 2014 ساعت 4:07 ب.ض
try:
api_key=' . $apikey
instead of:
api_key' . $apikey
ohh, and get a new API key, that one's public now :)
پاسخ توسط Travis Bell
در تاریخ ژانویه 5, 2014 ساعت 5:59 ب.ض
P.S. I just removed the API key from the original post.