在PHP中使用file_get_contents进行PUT请求的错误请求

ah

使用Postman(REST客户端)可以很好地进行此api调用,但是在我的GAE应用程序中的服务器上发出请求时,当前出现以下错误:

HTTP请求失败!在第26行的C:\ Projects \ app \ file.php中

无法打开流:HTTP请求失败!第26行的C:\ Projects \ app \ file.php中的HTTP / 1.0 400错误请求

这是我的应用程序中的代码,该代码调用其余的api方法/ exampleMethod

$dataraw = [ 
        'email' => '[email protected]',
        'first_name' => 'firstname',
        'last_name' => 'lastname',
        'fEmail' => '[email protected]',
        'message' => 'test' 
];
$data = http_build_query ( $dataraw );
$context = [ 
        'http' => [ 
                'method' => 'PUT',
                'header' => "Authorization: apikeystring\r\n" . "Content-Length: " . strlen($data) . "\r\n" . "Content-Type: application/json\r\n",
                'content' => $data,
                'proxy' => 'tcp://euproxy.example.com:0000' 
        ] 
];
$context = stream_context_create ( $context );
$result = file_get_contents ( $GLOBALS ['REST_API_URL'] . '/exampleMethod', false, $context );

在应用程序中,我已经成功地将file_get_contents用于GET请求,但是通过此PUT请求,我收到了一个400错误的请求,该请求不是来自Rest Api。

火星

将mb_strlen(serialize($ dataraw),'8bit')更改为strlen($ data)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在PHP中使用file_get_contents进行PUT请求的错误请求

来自分类Dev

file_get_contents('php:// input')返回带有PUT请求的空字符串

来自分类Dev

在php中使用file_get_contents

来自分类Dev

file_get_contents中的HTTP / 1.1 400错误请求

来自分类Dev

PHP:file_get_contents()HTTP / 1.0 400 Google Maps API的错误请求

来自分类Dev

file_get_contents,HTTP请求失败

来自分类Dev

file_get_contents HTTP请求失败

来自分类Dev

file_get_contents,HTTP请求失败

来自分类Dev

在functions.php中使用file_get_contents的WordPress?

来自分类Dev

无法在php中使用file_get_contents()

来自分类Dev

为什么我的POST file_get_contents返回HTTP错误请求?

来自分类Dev

使用PHP同步file_get_contents和file_put_contents函数

来自分类Dev

nodejs-获取类似于php的file_get_contents的请求正文

来自分类Dev

file_get_contents请求到外部站点

来自分类Dev

PHP file_get_contents为HTTP请求返回不一致的部分数据

来自分类Dev

如何在PHP中使用file_get_contents获取图像的MIME类型

来自分类Dev

是否有可能在PHP中使用file_get_contents破坏CSRF令牌验证

来自分类Dev

在 PHP 中使用 file_get_contents 时的会话身份验证

来自分类Dev

file_get_contents('index.php')的file_put_contents将编写PHP代码

来自分类Dev

如何获取php file_get_contents()错误响应内容

来自分类Dev

JSON使用file_get_contents对数组进行编码

来自分类Dev

如何使用PHP中的file_get_contents修复404错误?

来自分类Dev

来自csv的PHP file_get_contents()和file_put_contents

来自分类Dev

YouTube在使用file_get_contents时给我错误

来自分类Dev

file_get_contents无法打开流:仅针对SPECIFIC网页的HTTP请求失败

来自分类Dev

file_get_contents无法打开流:HTTP请求失败!HTTP / 1.1 463

来自分类Dev

无法通过file_get_contents在发布请求中发送数据

来自分类Dev

使用file_get_contents()PHP函数的正确方法

来自分类Dev

PHP向使用file_get_contents的函数添加Curl

Related 相关文章

  1. 1

    在PHP中使用file_get_contents进行PUT请求的错误请求

  2. 2

    file_get_contents('php:// input')返回带有PUT请求的空字符串

  3. 3

    在php中使用file_get_contents

  4. 4

    file_get_contents中的HTTP / 1.1 400错误请求

  5. 5

    PHP:file_get_contents()HTTP / 1.0 400 Google Maps API的错误请求

  6. 6

    file_get_contents,HTTP请求失败

  7. 7

    file_get_contents HTTP请求失败

  8. 8

    file_get_contents,HTTP请求失败

  9. 9

    在functions.php中使用file_get_contents的WordPress?

  10. 10

    无法在php中使用file_get_contents()

  11. 11

    为什么我的POST file_get_contents返回HTTP错误请求?

  12. 12

    使用PHP同步file_get_contents和file_put_contents函数

  13. 13

    nodejs-获取类似于php的file_get_contents的请求正文

  14. 14

    file_get_contents请求到外部站点

  15. 15

    PHP file_get_contents为HTTP请求返回不一致的部分数据

  16. 16

    如何在PHP中使用file_get_contents获取图像的MIME类型

  17. 17

    是否有可能在PHP中使用file_get_contents破坏CSRF令牌验证

  18. 18

    在 PHP 中使用 file_get_contents 时的会话身份验证

  19. 19

    file_get_contents('index.php')的file_put_contents将编写PHP代码

  20. 20

    如何获取php file_get_contents()错误响应内容

  21. 21

    JSON使用file_get_contents对数组进行编码

  22. 22

    如何使用PHP中的file_get_contents修复404错误?

  23. 23

    来自csv的PHP file_get_contents()和file_put_contents

  24. 24

    YouTube在使用file_get_contents时给我错误

  25. 25

    file_get_contents无法打开流:仅针对SPECIFIC网页的HTTP请求失败

  26. 26

    file_get_contents无法打开流:HTTP请求失败!HTTP / 1.1 463

  27. 27

    无法通过file_get_contents在发布请求中发送数据

  28. 28

    使用file_get_contents()PHP函数的正确方法

  29. 29

    PHP向使用file_get_contents的函数添加Curl

热门标签

归档