【问题标题】:PHP execute curl OauthPHP执行curl Oauth
【发布时间】:2016-09-11 21:47:36
【问题描述】:

我想使用 curl 发送以下标头:

curl -H 'Authorization: OAuth oauth_signature_method="PLAINTEXT",⤦
⤥oauth_consumer_key="xxx",oauth_token="xxx",oauth_signature="xxx"' ⤦
⤥'https://external.ningapis.com/xn/rest/apiexample/1.0/Photo/recent⤦
⤥?xn_pretty=true&fields=image.url,title&count=2'

以上命令用于命令行使用。有人知道如何使用 PHP curl 执行此操作吗?

【问题讨论】:

  • 这些是你真正的钥匙吗,我想知道......)

标签: php curl oauth


【解决方案1】:

来自 curl 命令行的 -H 在 PHP curl curl_setopt 中是 CURLOPT_HTTPHEADER

这应该是您需要的最基本示例:

$auth = 'Authorization: YOUR_KEYS';
$url  = 'https://external.ningapis.com/xn/rest/apiexample/1.0/Photo/recent?xn_pretty=true&fields=image.url,title&count=2';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array($auth));
curl_exec($ch);
curl_close($ch);

【讨论】:

    猜你喜欢
    • 2012-02-19
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 2017-06-03
    • 2018-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多