나는 포도 나무 스크립트를 만들고 있으며 .jpg
아래에서 볼 수 있듯이 내 스크립트에 의해 설정된 선택된 포도 나무 비디오 URL에서 썸네일을 수집하려고합니다.og:image:secure_url
<meta property="og:image:secure_url" content="{php} echo vine_pic($this->_tpl_vars['p']['youtube_key']);{/php}" />
도움이 필요한 것
설정 string limit
의 147
문자. 덩굴 동영상 URL에서 엄지 손가락이 생성되면 다음과 같이 나타납니다.
https://v.cdn.vine.co/r/thumbs/6A6EB338-0961-4382-9D0D-E58CC705C8D5-2536-00000172EBB64B1B_1f3e673a8d2.1.3.mp4.jpg?versionId=i7r_pcP2P1noapLmoI0QgrtvsD8ii43f
og:image:secure_url
나열된 추가 문자가 포함되어 있으면 올바르게 읽히지 않습니다.
?versionId=i7r_pcP2P1noapLmoI0QgrtvsD8ii43f
문자열 제한을 넣는 내 코드
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;
// As you see below, I made an attempt but it doesn't work.
substr(0, 147, $vine, $matches);
}
귀하의 substr()
구문이 올바르지 않습니다.
실제로는 다음과 같아야합니다.
substr ($string, $start, $length)
를 사용하려면 substr()
다음과 같이 미리보기 이미지 URL을 변수에 저장해야합니다.
function vine_pic( $id )
{
$vine = file_get_contents("http://vine.co/v/{$id}");
preg_match('/property="og:image" content="(.*?)"/', $vine, $matches);
$thumb = ($matches[1]) ? $matches[1] : false;
$thumb = substr($thumb, 0, 147);
return $thumb;
}
$thumb
사용하기 전에이 설정 되어 있는지 확인하는 것이 좋습니다 substr()
.
if ($thumb) {
$thumb = substr($thumb, 0, 147);
return $thumb;
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다