gpt4 book ai didi

php - Kohana 3.2 中的外部 GET 请求通过工厂方法剥离

转载 作者:行者123 更新时间:2023-12-03 23:05:23 25 4
gpt4 key购买 nike

我正在尝试发出外部请求。我正在关注提供的示例 here in Kohana Docs .

事实是,我正在尝试使用 GET 参数执行 GET。只要我向工厂方法提供带有 GET 参数的 URL,参数就会从 URL 中剥离并放置在 Request 对象的 _get 属性中。

这是我这边的样子:

$request = Request::factory('http://www.example.com/api.php?param1=value1&param2=value2');
$response = $request->execute();

如果我print_r $request 对象我可以看到这个(摘录):

[_get:protected] => Array
(
[param1] => value1
[param2] => value2
)

但不幸的是,在执行请求时,这些看起来并没有被发送。

为什么会这样?

最佳答案

使用 query()方法来设置 GET 数据。

$request = Request::factory('http://www.example.com/api.php')->query(array('param1' => 'value1', 'param2' => 'value2'));
$response = $request->execute();

关于php - Kohana 3.2 中的外部 GET 请求通过工厂方法剥离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10434723/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com