php - Purging & Removing Part of URL -
i creating vine video sharing website.
i having issues. og:image:secure_url won't pick right because url getting displayed this..
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
so facebook giving me error when bebugging..
object @ url 'http://vinesandstuff.com/' of type 'article' invalid because given value '' property 'og:image:secure_url' not parsed type 'url'.
how it's setup in backend..
the og:image:secure_url setup, note script uses smarty code.
<meta property="og:image:secure_url" content="{php} echo vine_pic($this->_tpl_vars['p']['youtube_key']);{/php}" />
and script grabs og:image 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; }
what need with
is removing end part of url ?versionid=jq9yuwcebry1sgzpzu40z3wc_vf_pmb1
i looked other stackoverflow questions don't quite understand how should setup in syntax. me? appreciated.
use parse_url
, http_build_query
tear url apart , put without versionid
i've never used smarty tags, i'm not sure part. in php i'd this: (untested)
$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 above missing slash, change dot .'/'. ?> <meta property="og:image:secure_url" content="<?php echo $new_pic_link; ?>">
Comments
Post a Comment