curl
(またはcURL
)は、URLにアクセスするためのコマンドラインツールです。
ドキュメント:http ://curl.haxx.se/docs/manpage.html
この例では、POSTをに送信しているだけhttps://graph.facebook.com/arjun/feed
です。は-F
、POSTで送信されるパラメータを定義しています。
これはjavascriptまたはphpではありません。phpでcurlを使用できますが、これらのパラメーターを使用してそのアドレスにPOSTを実行すると、例が示していることを実行できます。
これをJavaScriptで行うには、フォームを作成してから送信します。
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", "https://graph.facebook.com/arjun/feed");
var tokenField = document.createElement("input");
tokenField.setAttribute("type", "hidden");
tokenField.setAttribute("name", "access_token");
tokenField.setAttribute("value", token);
var msgField = document.createElement("input");
msgField.setAttribute("type", "hidden");
msgField.setAttribute("name", "message");
msgField.setAttribute("value", "Hello, Arjun. I like this new API.");
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
jQueryを使用すると、はるかに簡単になります。
$.post("https://graph.facebook.com/arjun/feed", {
access_token: token,
message: "Hello, Arjun. I like this new API."
});