在 PHP 中使用 Kohana 3.2 发布 JSON 字符串
运行正常的 post 操作时,我使用以下代码:
$request = Request::factory($url)->method(Request::POST)->post($params);
$response = $request->execute();
我不确定需要更改什么才能使我能够 POST json 字符串而不是数组变量。
我的 json 字符串基本上是使用参数数组上的 json_encode() 函数创建的,如下所示:
$params = array(
'var1' => $var1,
'var2' => $var2,
// etc
);
$json = json_encode($params);
任何帮助将不胜感激。
When running normal post operations I use the following code:
$request = Request::factory($url)->method(Request::POST)->post($params);
$response = $request->execute();
I'm not sure what it is I need to change though to enable me to POST a json string instead of an array variable.
My json string is basically created using the json_encode() function on an array of parameters, like so:
$params = array(
'var1' => $var1,
'var2' => $var2,
// etc
);
$json = json_encode($params);
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
我已经找到了这些解决方案。
使用 PUT:
使用 POST:
从这里: http://kohanaframework.org/3.2/指南/kohana/requests#external-requests
I have found these solutions.
Using PUT:
Using POST:
From here: http://kohanaframework.org/3.2/guide/kohana/requests#external-requests