php curl 扩展可以帮助我们快速实现http请求。
在使用豆瓣oauth登录接口时,我们需要发送这样的http request 请求:
get /v2/user/~me http/1.1host: https://api.douban.comauthorization: bearer a14afef0f66fcffce3e0fcd2e34f6ff4
在命令行中我们这样执行:
curl https://api.douban.com/v2/user/~me -h authorization: bearer a14afef0f66fcffce3e0fcd2e34f6ff4
php curl 发送 authorization http 请求http curl 执行 post? 方法:
$crl = curl_init();$headr = array();$headr[] = 'authorization: '.$douban_user_name.' '.$accesstoken;curl_setopt($crl, curlopt_httpheader,$headr);curl_setopt($crl, curlopt_post,true);$rest = curl_exec($crl);curl_close($crl);print_r($rest);
如果需要http curl实现get请求,请看下面:
(...)
read the rest of php curl 执行 authorization 请求 (34 words)
© li xi for lixiphp, 2014. |permalink |no comment |add todel.icio.us
post tags: authorization, curl, get, http, post
feed enhanced by better feed from ozh
