我面临的问题
当我们检索说明http://youtu.be/YFZ2L0sNzvM?a的网址被重定向时。
当我在浏览器上复制粘贴此网址时,我们会检索错误的网址http://t.co/hNLWmspb,并重定向https://www.youtube.com/watch?v=XzqagJTsNrc&feature=youtu.be。
所以我检索了http://t.co/hNLWmspb,以便如何将链接重定向到您的网址。
此行中的错误
/* bug in this line */
/* $media_url = 'http://t.co/hNLWmspb' */
/** how to solve this issue when url is retrive that is not you redirection url.*/
<a href='.$media_url.' class="html5lightbox" data-group=""
titl="'.$tweet_content.'">';
源代码
if(isset($row['videoUrl']) && $row['videoUrl']!='null')
{
$v = $row['videoUrl'];
$v_url=array();
$v_url=explode(",",$v);
foreach($v_url as $video_url)
{
$video_url = str_replace('http://vimeo.com','//player.vimeo.com/video',$video_url);
$video_url = explode('&',$video_url);
$media_url=$video_url[0];
// echo strtok('?v=');
if( ($x_pos = strpos($media_url, '?v=')) !== FALSE ){
$default_image = '"http://img.youtube.com/vi/'.substr($media_url, $x_pos + 3).'/0.jpg"';
if( ($x_pos1 = strpos($default_image, '#')) !== FALSE ){
//echo substr($default_image, 0,$x_pos1);
$default_image=substr($default_image, 0,$x_pos1).'/0.jpg"';
}
}
}//foreach of $v_url
//echo $media_url;$pos = strpos($mystring, $findme);
$tweet_content="
<div style='display: block; overflow: hidden; margin:0 8px 8px 8px;' id='html5-text'>
<p id='boxscroll' class='twt' style='overflow: hidden; font-size:.9em; line-height:1.5em;margin-bottom:.5em!important' tabindex='5000;'>".htmlentities($this->linkify($row['tweetText']))."
<div class='twtdetail' style='font-size:.9em; line-height:1em'>
<img width='45' src=". $row['profileImageUrl']."
class='image round left' style='margin:0 .5em 0 0!important'> ".htmlentities($row['name'])."<br><span class='via' style='font-size:.8em'>via Twitter<br>".$this->twitter_time($row['tweetedAt'])."</span>
</div>
</div>
</div>";
$content='<div class="4u"><div class="box photo tile">
/* bug in this line */
/* $media_url = 'http://t.co/hNLWmspb' */
/** how to solve this issue when url is retrive that is not you redirection url.*/
<a href='.$media_url.' class="html5lightbox" data-group=""
titl="'.$tweet_content.'">';
if(strpos($media_url, 'youtube')){
$content.='<span class="video"></span><img src='.$default_image.' style="width:100%; height:155px" class="image" >';
}else{
$content.='<span class="video"></span><img src='.$default_image.' style="width:100%; height:155px" class="image" >';
}
$content.='</a></div></div>';
$html[$n]=$content;