<?php
$title = urlencode('Nature');
$url = urlencode('http://amazingpics.net/content/Nature/Amazing%20Nature%20698.jpg');
$image = urlencode('http://trainees.ocs.org/training/hariharan/01-09-2014/images/img2.jpg');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sharing Images</title>
<link href="css/share.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="all">
<div class="top">
<div class="nature" align="center">
<p class="nat">I LOVE NATURE</p>
</div>
<p> </p>
<div class="img"><img src="images/img2.jpg" height="250" width="500" /></div>
<div class="share"><a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title;?>&p[url]=<?php echo $url; ?>&&p[images][0]=<?php echo $image;?>','sharer','toolbar=0,status=0,width=600,height=400');" href="javascript: void(0)"><img src="images/share.png" width="200" height="40" /></a></div>
<div class="share"><a onClick="window.open('http://twitter.com/intent/tweet?url=<?php echo $url;?>','sharer','toolbar=0,status=0,width=600,height=400');" href="javascript: void(0)"><img src="images/twitter.png" width="200" height="40" /></a></div>
<p> </p>
</div>
</div>
</body>
</html>
我尝试了上面的代码来在Facebook和Twitter上分享图片。在Facebook上它可以正常工作,但是在Twitter上无法显示图片,只显示链接。请帮助我在PHP中分享图片到Twitter。提前感谢...