PHP执行curl Oauth [英] PHP execute curl Oauth

查看:142
本文介绍了PHP执行curl Oauth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to send the following header using 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'


$ b b

Above命令用于命令行使用。任何人都知道如何使用PHP curl执行此操作?

Above command is for command line usage. Anyone know how to execute this using PHP curl?

推荐答案

-H from curl command-line is CURLOPT_HTTPHEADER in PHP curl curl_setopt

The -H from curl command-line is CURLOPT_HTTPHEADER in PHP curl curl_setopt.

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

This should be the most basic example for what you need:

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

这篇关于PHP执行curl Oauth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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