Welcome Guest, Not a member yet? Register   Sign In
Curl
#2

[eluser]Cristian Gilè[/eluser]
Add the following method to your controller (or library or helper):

Code:
function get_video_from_url($link)
{  
    $ch = curl_init();  
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch,CURLOPT_URL,$link);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result=curl_exec($ch);
    curl_close($ch);
    return $result;
}

call the new method and save the file locally:

Code:
$video = $this->get_video_from_url("http://vod.cms.download.performgroup.com/omnisport/ready/french/162/fr-050612-ireland_1338883384151_162.m4v");

if ( ! write_file('./video.m4v', $video))
{
    echo 'Unable to write the file';
}
else
{
    echo 'File written!';
}


Messages In This Thread
Curl - by El Forum - 06-05-2012, 01:54 AM
Curl - by El Forum - 06-05-2012, 02:17 AM
Curl - by El Forum - 06-05-2012, 02:21 AM
Curl - by El Forum - 06-05-2012, 02:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB