Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
Using google api and getting undefined offset error
Post Body

i know that many have asked for help regarding "undefined offset: 0" and i think i know what it means (no value at this position) but i cant figure out why i get this error.

i want to use a txt filled with youtube ids and get the titles back. It works without a problem if i type in the ids directly, but if i use the variable $video_id i get the error "undefined offset: 0"

<?php

$ids = file("ids.txt");

for($i=0;$i<count($ids);$i ){

$video_id = $ids[$i];

$api_key = 'MY_API_KEY';

$api_url = 'https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails,statistics&id='.$video_id.'&key='.$api_key;

$data = json_decode(file_get_contents($api_url));

echo $data->items[0]->snippet->title;

echo $video_id;

}

?>

Can someone help and tell me why that doesnt work?

Author
Account Strength
90%
Account Age
11 years
Verified Email
Yes
Verified Flair
No
Total Karma
2,445
Link Karma
1,457
Comment Karma
988
Profile updated: 6 days ago
Posts updated: 6 days ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago