Hello,

I ran into the following problem after upgrading to this version of media:youtube. I still can add videos from other providers (vimeo etc.)

- Warning: get_headers() [function.get-headers]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in MediaInternetYouTubeHandler->valid_id() (line 27 of /XXX/D7/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc).
- Warning: get_headers() [function.get-headers]: This function may only be used against URLs in MediaInternetYouTubeHandler->valid_id() (line 27 of /XXX/D7/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc).
- The YouTube video ID is invalid or the video was deleted.

I tried it with several videos which surely are not deleted! And I defined allow_url_fopen = On in a custom php.ini

Would it solve to problem to returning to a previous version of this module? About any help in regards to this I would be really glad!

SDK

Comments

sdk’s picture

I switched back to the alpha5 version and it is working. I assume this is still an issue with the beta1 version though....

ckopack’s picture

That did it for me too. Just FYI I am using Media 2.x unstable, Media gallery 1.x 7beta, media browser plus 7.x 1beta3. I had a bunch of problems today all related to the embedded media. The alpha seems to work fine.

Thanks sdk BTW

defiantbyte’s picture

Status: Active » Needs review
StatusFileSize
new1.15 KB

I had the same issue when I moved a site to production. I've attached a patch that uses cURL as a fallback option for when get_headers fails.

triple5’s picture

Can you tell us please if this fix is also included in 7.x-1.0-beta2 ?

DJ C’s picture

here is a fast fix for the
'get_headers not supported by all php implementations'
problem:

MediaInternetYouTubeHandler.inc

public function valid_id($id) {
$url = 'http://gdata.youtube.com/feeds/api/videos/'. $id;
$response = drupal_http_request($url);
$valid = ($response->code == 200);
// $headers = get_headers($url);
// $valid = strpos($headers[0], '200') !== FALSE;

if (!$valid) {
throw new MediaInternetValidationException(t('The YouTube video ID is invalid or the video was deleted.'));
}
return $valid;
}

defiantbyte’s picture

#4 (triple5) I don't think this patch has been included in beta1

#5 (DJ C) This looks like a cleaner fix than what I originally posted. Would you mind attaching a patch with it?

defiantbyte’s picture

Put DJ C's suggestion into the patch as opposed to the cURL fallback. Patch now uses drupal_http_request.

dave reid’s picture

Status: Needs review » Fixed

This was fixed with #1480556: Use drupal_http_request() instead of get_headers() in MeidaInternetYouTubeHandler::valid_id(), sorry I didn't see that it was a duplicate of this issue first.

littlemisssunshine’s picture

I'm using the latest dev version and I'm still seeing this error.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mbruneel’s picture

Are you behind a proxy? media_youtube uses drupal_http_request() to check if video is valid. Have a look at proxy section in your settings.php file.