I am trying to put comments on Facebook wall using jquery.
But my ajax call not alowing external url .
can anyone explain how can we use external url with jq
I think the only way is by using internel PHP code like MANOJ and Fernando suggest.
curl post/get in php file on your server --> call this php file with ajax
The PHP file let say (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);
Than use AJAX GET to
fb.php?commentmeta=your comment goes here
from your server.
Or do this with simple HTML and JavaScript from externel server:
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>