Obtener enlace redireccionado de imdb

  • Autor Autor xaiborweb
  • Fecha de inicio Fecha de inicio
xaiborweb

xaiborweb

Programador
No recomendado
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
hola, estoy intentando obtener el enlace official pague de una movie en imdb así:
PHP:
<?php
$id_imdb='tt0499549';
$ch=curl_init('http://www.imdb.com/title/'.$id_imdb.''); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.imdb.com/');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36');
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Accept-Language: en'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$results = curl_exec($ch); 
curl_close($ch);
preg_match_all("(Official Sites:</h4>(.*)Official site</a>)siU", $results, $official);	
preg_match_all("(<a href=\"(.*)\")siU", $official[1][0], $oficial);
for($o = 0; $o<count($oficial[1]);$o++){
	echo $url_oficial='http://www.imdb.com/'.$oficial[1][$o];
}
que me entrega este enlace
PHP:
http://www.imdb.com//offsite/?page-action=offsite-facebook&token=BCYlARusGn_t_tzGW59aTQQtP_O_iRaf0tvDQf8ntHGXDp-CP6dxeO-sixI4gtbnnvq9JrIO2qqY%0D%0AYYOsfLRmWyaEsnbVvP2PeSUJMW2hrwcNlQpNNxdT_3GPgLXl7jsF60KWB7YRdgHrgdzh_LlJFK1z%0D%0A_4sIFY9HtdOsX4wpYslkmfyBp6fA1qXPuJWK9EhYwp68_047lpxHvA_8JLlsi8Yf8aZolKhlJlGM%0D%0AfofEmY-xaOI%0D%0A&ref_=tt_pdt_ofs_offsite_0
el cual en el navegador redirecciona a este otro el cual es el que quiero obtener.
PHP:
https://www.facebook.com/avatar.oficial/?brand_redir=82771544063
estoy intentando obtenerlo así
PHP:
$lik = get_headers($url_oficial, true); 
	echo $lik["Location"];
pero no funciona, y me preguntaba si sabrán que puedo estar haciendo mal? gracias.

- - - Actualizado - - -

solucionado por si alguien le sirve

PHP:
$link=(get_headers($url_oficial,1)["Location"]);
echo $link[0];
 
Pode s hacerle curl a este link
Insertar CODE, HTML o PHP:
http://urlxray.com/display.php?url=http%3A%2F%2Fwww.imdb.com%2F%2Foffsite%2F%3Fpage-action%3Doffsite-facebook%26token%3DBCYlARusGn_t_tzGW59aTQQtP_O_iRaf0tvDQf8ntHGXDp-CP6dxeO-sixI4gtbnnvq9JrIO2qqY%250D%250AYYOsfLRmWyaEsnbVvP2PeSUJMW2hrwcNlQpNNxdT_3GPgLXl7jsF60KWB7YRdgHrgdzh_LlJFK1z%250D%250A_4sIFY9HtdOsX4wpYslkmfyBp6fA1qXPuJWK9EhYwp68_047lpxHvA_8JLlsi8Yf8aZolKhlJlGM%250D%250AfofEmY-xaOI%250D%250A%26ref_%3Dtt_pdt_ofs_offsite_0
 
Última edición:
[MENTION=35077]xaiborweb[/MENTION] prueba con esto man!

PHP:
<?php
function getUrl($url){
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $U);
	curl_setopt($ch, CURLOPT_HEADER, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$res = curl_exec($ch);
	curl_close($ch);
	preg_match('/Location:(.*?)\n/', $res, $matches);
	return trim(array_pop($matches));
} 

$id_imdb = 'tt0499549';
$ch = curl_init('http://www.imdb.com/title/'.$id_imdb.'/'); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.imdb.com/');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36');
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Accept-Language: en'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$results = curl_exec($ch); 
curl_close($ch);
preg_match_all('(Official Sites:</h4>(.*)Official site</a>)siU', $results, $official);    
preg_match_all('(<a href=\"(.*)\')siU', $official[1][0], $oficial);
for($o = 0; $o < count($oficial[1]); $o++){
	$url_oficial = 'http://www.imdb.com/'.$oficial[1][$o];
	echo getUrl($url_oficial);
}
?>
 
[MENTION=35077]xaiborweb[/MENTION] prueba con esto man!

PHP:
<?php
function getUrl($url){
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $U);
	curl_setopt($ch, CURLOPT_HEADER, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$res = curl_exec($ch);
	curl_close($ch);
	preg_match('/Location:(.*?)\n/', $res, $matches);
	return trim(array_pop($matches));
} 

$id_imdb = 'tt0499549';
$ch = curl_init('http://www.imdb.com/title/'.$id_imdb.'/'); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.imdb.com/');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36');
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Accept-Language: en'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$results = curl_exec($ch); 
curl_close($ch);
preg_match_all('(Official Sites:</h4>(.*)Official site</a>)siU', $results, $official);    
preg_match_all('(<a href=\"(.*)\')siU', $official[1][0], $oficial);
for($o = 0; $o < count($oficial[1]); $o++){
	$url_oficial = 'http://www.imdb.com/'.$oficial[1][$o];
	echo getUrl($url_oficial);
}
?>

ya lo había solucionado xd muchas gracias. hay había compartido como lo solucione.
 
[MENTION=35077]xaiborweb[/MENTION] si, lo vi despues que lo publique... tienes mucho tiempo en ese proyecto o es otro ?
 

Temas similares

Atrás
Arriba