略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: OAuth::getRequestHeader

2024-11-14

OAuth::getRequestHeader

(No version information available, might only be in Git)

OAuth::getRequestHeader生成 OAuth 头信息字符串签名

说明

public OAuth::getRequestHeader(string $http_method, string $url, mixed $extra_parameters = ?): string

生成基于最终 HTTP 方法、URL 和 一个字符串/数组附加参数的 OAuth 头信息字符串签名。

参数

http_method

请求的 HTTP 方法。

url

请求的 URL 。

extra_parameters

字符串或数组类型的附带参数。

返回值

返回 一个包含生成的请求头信息的字符串 r 或者在失败时返回 false

add a noteadd a note

User Contributed Notes 1 note

up
7
me at chrishowie dot com
5 years ago
The documentation does not specify the difference between passing a string and passing an array for the third parameter.  We spent two days debugging before reading the C source code to figure out that there is a significant and undocumented difference between the two.

"a=1" and array("a" => 1) are handled very differently!

If you are making a POST/PUT request (or anything with an entity body) then you should pass that as a string.

If you are making a request with a query string, you should pass that as an associative array.

If you pass "a=1" intending that to specify the query string, the generated signature will be invalid -- it will process this as if you were POSTing the content "a=1" instead.

官方地址:https://www.php.net/manual/en/oauth.getrequestheader.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3