2013-10-07 93 views
0

我正在创建藤蔓视频分享网站。清除并删除URL的一部分

我有一些问题。我OG:图片:将SECURE_URL不拿起正确的,因为该网址是越来越显示这样的..

https://v.cdn.vine.co/v/thumbs/2013/04/30/5D309EAF-962F-41E1-8F22-41E4AA50FFB7-967-00000195162F03BD_1.0.7.mp4.jpg?versionId=JQ9YuwCeBry1sGZpZU40Z3wc_VF_PMb1 

所以,Facebook是bebugging时候给我这个错误..

Object at URL 'http://vinesandstuff.com/' of type 'article' is invalid because the given value '' for property 'og:image:secure_url' could not be parsed as type 'url'. 

它是如何的设置在后端..

og:image:secure_url setup,注意脚本使用Smarty代码。

<meta property="og:image:secure_url" content="{php} echo vine_pic($this->_tpl_vars['p']['youtube_key']);{/php}" /> 

,并且抓住OG脚本:Twitter图片..

function vine_pic($id) 
{ 

$vine = file_get_contents("http://vine.co/v/{$id}"); 
             preg_match('/property="og:image" content="(.*?)"/', $vine, $matches); 

return ($matches[1]) ? $matches[1] : false; 

} 

我需要

帮助什么是删除网址的这端部?versionId=JQ9YuwCeBry1sGZpZU40Z3wc_VF_PMb1

我研究了其他的stackoverflow问题,但我不太明白应该如何在语法中设置它。有人能帮助我吗?非常感谢。

回答

0

使用parse_urlhttp_build_query来撕裂该URL,并把它重新走到一起不VERSIONID

我从来没有使用Smarty的标签,所以我不知道那一部分。在PHP我会做这样的事情:(未经测试)

$pic_link=vine_pic($this->_tpl_vars['p']['youtube_key']); 
$parsed=parse_url($pic_link); 
$pic_vars=parse_str($parsed['query']); 
unset($pic_vars['$parsed']); 
$new_query=http_build_query($pic_vars); 
$new_pic_link=$parsed['scheme'].$parsed['host'].$parsed['path']'?'.$new_query; 
//if the above is missing a slash, change the dot to .'/'. 
?> 
<meta property="og:image:secure_url" content="<?php echo $new_pic_link; ?>"> 
+0

hmm但我应该如何设置语法寿?我只有一个月的时间,并学习了很多时间,所以你不得不原谅我..我也试过这个,但我不知道我的后端脚本的哪一部分应该去哪里..'$ link = substr( $ linkraw,0,strrpos($ linkraw,“。”))' – Nelson

+0

你好TecBrat,我试过你的代码,更不用说''它叫'{php} {/ php}'但是我尝试了你的更新和'content ='用'?'输出 – Nelson

+0

请看我最近的编辑。我添加了“路径”。 – TecBrat