Facebook的API - 什么是"卷曲-F"? [英] Facebook API - What is " curl -F "?

查看:152
本文介绍了Facebook的API - 什么是"卷曲-F"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Facebook图形API(https://developers.facebook.com/docs/reference/api/):


  

出版:您可以通过发出HTTP POST请求到相应的连接网址,使用访问发布到Facebook的图
  令牌。例如,您可以通过张贴在阿琼的墙新墙后
  发出POST请求 https://graph.facebook.com/arjun/feed


 卷曲-F'的access_token = ...'\\
     -F的消息=您好,阿琼。我喜欢这个新的API。 \\
     https://graph.facebook.com/arjun/feed


  • Q1:这是一个JavaScript或php?

  • Q2:我没有看到卷曲-F
    函数引用无处可有人请给我一个?

非常感谢〜


解决方案

卷曲(或卷曲)是命令行工具访问的URL。

文档: http://curl.haxx.se/docs/manpage.html

在这个例子中,他们只是发送一个POST https://graph.facebook.com/arjun/feed 。在 -F 是定义与POST提交的参数。

这是不是JavaScript或PHP。您可以在PHP中使用卷曲,但任何POST与这些参数的地址将完成什么例子证明。

要在JavaScript做到这一点,你会创建一个表单,然后提交:

  VAR形式=使用document.createElement(表);
form.setAttribute(法,后);
form.setAttribute(行动,https://graph.facebook.com/arjun/feed);VAR tokenField =使用document.createElement(输入);
tokenField.setAttribute(类型,隐藏);
tokenField.setAttribute(姓名,的access_token);
tokenField.setAttribute(价值,令牌);VAR msgField =使用document.createElement(输入);
msgField.setAttribute(类型,隐藏);
msgField.setAttribute(姓名,消息);
msgField.setAttribute(价值,你好,我阿琼喜欢这个新的API。);form.appendChild(hiddenField);document.body.appendChild(表);
form.submit();

使用jQuery,这是一个简单多了:

  $。员额(https://graph.facebook.com/arjun/feed,{
    的access_token:令牌,
    消息:你好,我阿琼喜欢这个新的API。
});

From Facebook Graph Api (https://developers.facebook.com/docs/reference/api/) :

Publishing: You can publish to the Facebook graph by issuing HTTP POST requests to the appropriate connection URLs, using an access token. For example, you can post a new wall post on Arjun's wall by issuing a POST request to https://graph.facebook.com/arjun/feed:

curl -F 'access_token=...' \
     -F 'message=Hello, Arjun. I like this new API.' \
     https://graph.facebook.com/arjun/feed

  • Q1: is this a javascript or php ?
  • Q2: I don't see "curl -F" function reference nowhere, can someone pls show me one ?

Many thanks ~

解决方案

curl (or cURL) is a command-line tool for accessing URLs.

Documentation: http://curl.haxx.se/docs/manpage.html

In this example, they are simply sending a POST to https://graph.facebook.com/arjun/feed. The -F is defining parameters to be submitted with the POST.

This is not javascript or php. You can use curl in php, although any POST to that address with those parameters will accomplish what the example is demonstrating.

To do this in javascript, you would create a form and then submit it:

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();

Using jQuery, it's a lot simpler:

$.post("https://graph.facebook.com/arjun/feed", { 
    access_token: token, 
    message: "Hello, Arjun. I like this new API."
});

这篇关于Facebook的API - 什么是"卷曲-F"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆