问题
I am using
<?php $image='http://abc.in/def.jpg'; ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="twitter:card" content="summary">
<meta name="og:image" content="<?php echo $image?>">
<meta name="og:description" content="<?php echo $description; ?>">
<meta name="og:title" content="<?php echo $title; ?>">
<meta name="twitter:url" content="http://keyss.in">
<meta name="twitter:app:id:iphone" content="">
<meta name="twitter:app:id:ipad" content="">
<meta name="twitter:app:id:googleplay" content="">
<meta name="twitter:app:url:iphone" content="">
<meta name="twitter:app:url:ipad" content="">
<meta name="twitter:app:url:googleplay" content="">
</head>
</html>
code for my Twitter post.
When I pass static content in <meta name="og:image" content="http://abc.in/def.jpg">
image is posted on my Twitter wall, but if I pass variable as
<meta name="og:image" content="<?php echo $image?>">
image is not posted on my wall.
How can I pass dynamic variable in image content?
回答1:
The missing semicolon after $image could be the issue (as mentioned in the comments):
<meta name="og:image" content="<?php echo $image; ?>">
<meta name="og:description" content="<?php echo $description; ?>">
<meta name="og:title" content="<?php echo $title; ?>">
Once you've fixed the code, run the Page through the Twitter Card validator to make sure everything appears correctly. It should hopefully give you an idea of what's going wrong.
来源:https://stackoverflow.com/questions/22243526/how-to-pass-dynamic-image-path-in-twitter-card