我在第190行看不到任何错误:$query = “https://www.googleapis.com/youtube/v3/search?part=snippet&q=$search&maxResults=$per_page&videoCategoryId=$category&safesearch=strict&key=$apikey”;
<?php
error_reporting(1);
$movie = $_GET[movie];
$tmdb_api_key = '9366d6385a1a15cab92bdde8de2b98af'; // change it with your themoviedb.com API
$aff_link = 'http://google.com'; // your offer link
$image_host = 'http://image.tmdb.org/t/p/';
$json_tmdb = 'http://api.themoviedb.org/3/movie/'.$movie.'?api_key='.$tmdb_api_key.'&append_to_response=credits,images,trailers,keywords,releases,similar_movies';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $json_tmdb);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response);
if ($data->title == null) {
die;
}
$backdrop_to_background = $backdrop_to_player = 0;
$backdrops = count($data->images->backdrops);
if ($backdrops > 1) {
$backdrop_to_player = rand(0, $backdrops-1);
$backdrop_to_background = $backdrop_to_player;
while ($backdrop_to_background == $backdrop_to_player) {
$backdrop_to_background = rand(0, $backdrops-1);
}
}
$movie_title = $data->title;
$movie_runtime = $data->runtime;
$n = count($data->genres);
$i = 0;
$movie_genres = '';
while ($i <= $n-1) {
$movie_genres .= $data->genres[$i]->name;
if ($i < $n-1) {
$movie_genres .= ', ';
}
$i++;
}
$n = count($data->credits->cast);
$i = 0;
$movie_cast = '';
while ($i <= $n-1) {
$movie_cast .= $data->credits->cast[$i]->name . ' (' . $data->credits->cast[$i]->character . ')';
if ($i < $n-1) {
$movie_cast .= ', ';
}
$i++;
}
$movie_plot = $data->overview;
$movie_poster = $image_host.'w185'.$data->poster_path;
$movie_player = $image_host.'w780'.$data->images->backdrops[$backdrop_to_player]->file_path;
$movie_background = $image_host.'w780'.$data->images->backdrops[$backdrop_to_background]->file_path;
?>
<html>
<head>
<title>Watch <?php echo $movie_title;?> Full Movie</title>
<link href="img/favicon.ico" rel="shortcut icon">
<link href="http://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=Cabin" rel="stylesheet" type="text/css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
function(){
$("#player-play").click(
function(){
$("#player-container").attr("style","background: url(img/stripes.png); background-repeat : repeat; z-index: 1; width: 854px; height: 480px; margin: 100px auto; position: absolute; top:0; left:0; bottom:0; right:0; z-index: 1; opacity: 0.9; filter:alpha(opacity=90); border: 20px solid rgba(255, 0, 0, 0.3);");
$("#player-play").addClass("player-hidden");
$("#player-error").removeClass("player-hidden")
}
)
}
)
</script>
<style>
body {
margin : 0px 0px 0px 0px;
background-color: #060606;
}
.player-play {
width: 854px;
height: 480px;
background: url(img/inactive-button.png) no-repeat;
background-size: cover;
cursor: pointer;
z-index: 2;
}
.player-play:hover {
background : url(img/active-button.png) no-repeat;
}
.player-error {
padding-top : 22%;
max-width : 854px;
margin : 0 auto;
text-align : center;
line-height : 5px;
z-index : 2
}
.player-error p {
color : #fff;
font-size : 18px;
margin : 20px auto;
}
.player-error a {
color : #fff;
font-size : 22px;
text-decoration:underline;
}
.player-hidden {
display:none!important;
visibility:hidden!important;
}
.movie-title {
font-family: 'Lobster', Georgia, Times, serif;
font-size: 40px;
line-height: 50px;
color : #fff;
text-align: center;
margin-top: 15px;
}
.movie-plot {
font-family: 'Cabin', Helvetica, Arial, sans-serif;
font-size: 15px;
line-height: 20px;
color : #ffffff;
width: 854px;
margin : 570px auto;
text-align: justify;
}
</style>
</head>
<body>
<div class="movie-title">"<?php echo $movie_title; ?>" Full Movie</div>
<div style="background: url(<?php echo $movie_background;?>); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; opacity: 0.3; filter:alpha(opacity=30); position:absolute; top:0; left:0; width:100%; height:100%;"></div>
<div style="background: url(<?php echo $movie_player;?>); background-repeat : no-repeat; background-size: cover; z-index: 1; width: 854px; height: 480px; margin: 100px auto auto; position: absolute; top:0; left:0; bottom:0; right:0; z-index: 1; border: 20px solid rgba(255, 0, 0, 0.3);" id="player-container">
<div class="player-play" id="player-play"></div>
<div class="player-error player-hidden" id="player-error">
<img src="img/error.png" alt="error">
<p>A plugin is needed to display this video.</p>
<a href="<?=$aff_link;?>" target="_self">Install plugin...</a>
</div>
</div>
<div class="movie-plot">
<img src="<?php echo $movie_poster;?>" style="float: left; width: 120px; margin:0px 10px 10px 0px;">
<p><b>Title : </b> <?php echo $movie_title; ?></p>
<p><b>Genre : </b> <?php echo $movie_genres; ?></p>
<p><b>Cast : </b> <?php echo $movie_cast; ?></p>
<p><b>Movie Plot : </b><?php echo $movie_plot;?><br><br></p>
</div>
<?php
$apikey = “my api deleted for post”;
$per_page = 6;
$search = “lucy”;
$category = “2”; //autos
$query = “https://www.googleapis.com/youtube/v3/search?part=snippet&q=$search&maxResults=$per_page&videoCategoryId=$category&safesearch=strict&key=$apikey”;
$json_file3 = file_get_contents(“$query”);
$jfo3 = json_decode($json_file3,true);
foreach($jfo3[‘items’] as $val) {
$title = $val[‘snippet’][‘title’];
$description = $val[‘snippet’][‘description’];
$id = $val[‘id’][‘videoId’];
$thumbnail_url = $val[‘snippet’][‘thumbnails’][‘default’][‘url’];
echo <<<EOF
<p><img width = “250” src = “$thumbnail_url” align = “right”></a>
<a href =”video-viewer.php?v=$id”>$title<BR>
$description</p><br clear=”all”><HR>
EOF;
?>
</body>
</html>
答案 0 :(得分:0)
$query = "https://www.googleapis.com/youtube/v3/search?part=snippet&q=".$search."&maxResults=".$per_page."&videoCategoryId=".$category."&safesearch=strict&key=".$apikey;
这应该有效