dsij89625 2019-07-23 16:51
浏览 440

如何在网页上使用themoviedb API

I'm trying to use theMovieDB API for my website, it uses user inputted information such as IMDB ID, however I'm not sure how to get it to print the results, i can only get iframe working.

I'm new to API's and printing results etc so any help or information on usage would be great.

this is what my current code is for the iframe:

<iframe src="https://api.themoviedb.org/3/movie/{$video->imdb_id}?api_key=[API_KEY]&language=en-US" frameborder="0"></iframe>

Iv'e tried the pre-made code it generates on their site, such as the JQuery one and the three different PHP options however they don't print anything.

Thanks for any help :)

Here's the JQuery the site generated for me.

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.themoviedb.org/3/movie/tt6513656?language=en-US&api_key=[API_KEY]",
  "method": "GET",
  "headers": {},
  "data": "{}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

The cURL it generated.

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.themoviedb.org/3/movie/tt6513656?language=en-US&api_key=[API_KEY]",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_POSTFIELDS => "{}",
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

cURL output.

"https://api.themoviedb.org/3/movie/tt6513656?language=en-US&api_key=[API_KEY]", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_POSTFIELDS => "{}", )); = curl_exec(); = curl_error(); curl_close(); if () { echo "cURL Error #:" . ; } else { echo ; } ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥30 python代码,帮调试,帮帮忙吧
    • ¥15 #MATLAB仿真#车辆换道路径规划