发送POST服务器? (instagram api) [英] Send POST serverside? (instagram api)
问题描述
查看 http://instagram.com/developer/authentication/ - 推荐的方式通信是服务器端。
Looking at http://instagram.com/developer/authentication/ - The recommended way of communication is serverside.
我理解我如何做step1和step2。但在第3步他们希望我POST数据直接服务器? (我理解我如何做一个post请求从jQuery)但是,甚至可以直接从PHP / CodeIgniter?
I understand how I do step1 and step2. But in step3 they want me POST data directly serverside? (I understand how I could do a post request from jQuery) But is it even possible to do directly from PHP/CodeIgniter?
这基本上是step3:
This is basically step3:
在上一步中,您将收到一个代码,您将有
进行交换,以便为用户接收access_token 。为了使
进行这个交换,你只需要POST这个代码,连同
一些应用程序标识参数到我们的access_token端点。
In the previous step, you’ll have received a code which you’ll have to exchange in order to receive an access_token for the user. In order to make this exchange, you simply have to POST this code, along with some app identification parameters to our access_token endpoint.
我有这些信息:(来自Instagram的回复)
I have all this info: (from response from Instagram)
client_id: your client id
client_secret: your client secret
grant_type: authorization_code is currently the only supported value
redirect_uri: the redirect_uri you used in the authorization request. Note: this has to be the same value as in the authorization request.
code: the exact code you received during the authorization step.
推荐答案
后端可以像浏览器一样做POST。
A backend can do a POST just like the browser. Much of the internet is server-to-server communication in this manner.
以下是PHP中的一个示例POST请求(使用Curl)
Here's an example POST request in PHP (using Curl)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.example.com/site.html");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "postvar1=value1&postvar2=value2");
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec ($ch);
curl_close ($ch);
另一种设置POST参数而不是手动创建param字符串的方法:
An alternative way to set the POST parameters instead of manually creating the param string:
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(array('postvar1' => 'value1')));
这篇关于发送POST服务器? (instagram api)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!