我认为唯一的方法是使用像MANOJ和Fernando建议的内部PHP代码。
在您的服务器上的PHP文件中进行curl post/get --> 使用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);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"message=".$commentdata);
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>