Skip to main content

[PHP] Simple function to get link and download video on Facebook

http://png-2.findicons.com/files/icons/1035/human_o2/128/application_x_php.png 
 
Chia sẻ với các bạn một đoạn PHP đơn giản do mình viết để lấy link download video trên Facebook.

<?php
/**
 * @name Simple function to get link and download video on Facebook
 * @author Juno_okyo & Killer
 * @copyright 2013 by J2TeaM
 */

$url = 'https://www.facebook.com/photo.php?v=464181973622841&set=vb.405529542805619&type=3';

_Download($url);

function _Download($url) {
    $useragent = 'Mozilla/5.0 (Linux; U; Android 2.3.3; de-de; HTC Desire Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1';
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    $source = curl_exec($ch);
    curl_close($ch);
    
    $download = explode('/video_redirect/?src=', $source);
    $download = explode('&amp', $download[1]);
    $download = rawurldecode($download[0]);
    header('Location: ' . $download);
    exit();
}
?>

Các bạn có thể thêm một đoạn GET để có thể download theo dạng ?url=LINK_VIDEO.

Share this with your friends
Loading...