1

I tried to include iframe videos in my php, like this one Vk Video, so my php file will do the exact job as that video page, but i haven't gone so far, i tried file_get_contents but i got Warning with https videos. so is there any way that i can include http and https pages inside my php file?

note: i am bad at English so sorry ...

note: i am beginner in php ...

Zakaria Esbaiy
  • 123
  • 1
  • 12

1 Answers1

1

Like this:

function get_web_page( $url )
{
$options = array(
    CURLOPT_RETURNTRANSFER => true,     // return web page
    CURLOPT_HEADER         => false,    // don't return headers
    CURLOPT_FOLLOWLOCATION => true,     // follow redirects
    CURLOPT_ENCODING       => "",       // handle all encodings
    CURLOPT_USERAGENT      => "spider", // who am i
    CURLOPT_AUTOREFERER    => true,     // set referer on redirect
    CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
    CURLOPT_TIMEOUT        => 120,      // timeout on response
    CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
    CURLOPT_SSL_VERIFYPEER => false     // Disabled SSL Cert checks
);

$ch      = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err     = curl_errno( $ch );
$errmsg  = curl_error( $ch );
$header  = curl_getinfo( $ch );
curl_close( $ch );

$header['errno']   = $err;
$header['errmsg']  = $errmsg;
$header['content'] = $content;
echo $content;
}
get_web_page( 'http://vk.com/video_ext.php?oid=250349454&id=169859391&hash=af2327b1f2db9f87&hd=1' );
Kohjah Breese
  • 4,008
  • 6
  • 32
  • 48
  • I've seen that function on SO before, care to reference where you copied it from? – scrowler Sep 14 '14 at 21:15
  • It's referenced in the comments above. If I wanted to take credit for this not particularly well-written code I would have just bundled it straight into an answer rather than posting it as a comment, which often get no reward. Didn't think it was worth the duplication. OP is having issues with HTTPS in PHP; Q has been answered several times. – Kohjah Breese Sep 15 '14 at 00:32
  • 1
    That's what the flag as duplicate option is for. Referencing your answer would be beneficial as often people don't read comments – scrowler Sep 15 '14 at 00:52
  • Thanks, I was not aware of that facility. – Kohjah Breese Sep 15 '14 at 01:07