String question....

[php]
$api = file_get_contents(‘https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=25&playlistId=UU8EE4Ut5WkXHqMZJcd2vG3w&key=AIzaSyBw1asGhkxHxFf6JqyNrTqIeJ9sjMKde3w’);
[/php]

That is what I have an I have tried every version of how to put php variable in there… but it’s a no go…
I have an $id, $maxVids and $key that I would like to do this with:

playlistId=$id
key=$key
maxResults=$maxVids

Trust me when I say I’ve tried to do this in every way I could think of and find… nothing seems to be working…
Just want it that way so I can make changes on the fly… quick and easy without opening up files…etc…

Suggestions? I’ve put them in “”, ‘’, “’’”, . $id . and every other way there is to do but no good. It would be awesome and easy if these were NOT equal to a $variable already I would just use the <?= $id ?> but since it’s already in the php tag I can’t do that either… [NOT to worry that’s not a real key ;)]…

Thanks!

Not exactly sure what you are doing, but this does work:
[php]
$testString = ‘#q=phphelp’;

$api = file_get_contents(“https://www.google.com/$testString”);

echo $api;[/php]

Well it’s not working for me… not sure why either…

This is what I want…

$api = file_get_contents(‘https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=$maxVids&playlistId=$id&key=$key’);

No matter how I format it… it returns nothing…

Double quotes…singles quotes… nothing… tried this:
“’$id’”
“.$id.”
‘.$id.’
“’.$id.’”

Tried em all… returns nothing or just crashes the page…

since it’s already in <?php tags I can't do the <?= $id ?>…

Here’s the answer:

file_get_contents(“https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=$maxVids&playlistId=$id&key=$key”);

:slight_smile:

Thank you for the suggestion!! :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service