1
0
Fork 0

oembed: don't try to fetch media files and add Accept request header to fetch_url

This commit is contained in:
Fabio Comuni 2011-11-17 13:40:11 +01:00
commit 02281be0c3
2 changed files with 29 additions and 15 deletions

View file

@ -5,7 +5,7 @@
// results.
if(! function_exists('fetch_url')) {
function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) {
function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_content=Null) {
$a = get_app();
@ -14,9 +14,17 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0) {
return false;
@curl_setopt($ch, CURLOPT_HEADER, true);
if (!is_null($accept_content)){
curl_setopt($ch,CURLOPT_HTTPHEADER, array (
"Accept: "+$accept_content
));
}
@curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
@curl_setopt($ch, CURLOPT_USERAGENT, "Friendika");
if(intval($timeout)) {
@curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
}