我认为唯一的方法是使用像 MANOJ 和 Fernando 建议的内部 PHP 代码。
curl 发布/获取服务器上的 php 文件 --> 使用 ajax 调用此 php 文件
PHP文件让我们说(fb.php):
$commentdata=$_GET['commentdata'];
$fbUrl="https://graph.facebook.com/16453004404_481759124404/comments?access_token=my_token";
curl_setopt($ch, CURLOPT_URL,$fbUrl);
curl_setopt($ch, CURLOPT_POST, 1);
// POST data here
curl_setopt($ch, CURLOPT_POSTFIELDS,
"message=".$commentdata);
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
echo $server_output;
curl_close ($ch);
比使用 AJAX GET 来
fb.php?commentmeta=your comment goes here
从你的服务器。
或者使用来自外部服务器的简单 HTML 和 JavaScript 执行此操作:
Message: <input type="text" id="message">
<input type="submit" onclick='PostMessage()'>
<script>
function PostMessage() {
var comment = document.getElementById('message').value;
window.location.assign('http://yourdomain.tld/fb.php?commentmeta='+comment)
}
</script>