【发布时间】:2017-06-22 05:04:05
【问题描述】:
因此,在使用交互式消息时,我在尝试从 Slack 取回有效负载时遇到了一些麻烦。我用按钮发送消息。我已经正确设置了所有内容,Slack 可以很好地访问我的返回 URL。
问题是我不知道如何从请求中检索“有效负载”? Slack 文档说:
“您的操作 URL 将收到一个 HTTP POST 请求,包括一个有效负载主体参数,它本身包含一个 application/x-www-form-urlencoded JSON 字符串。”
我想我不知道这意味着什么。我认为这意味着你会得到一个“有效负载”的 POST 变量,但事实并非如此。
在 Laravel 中,我正在使用以下内容来尝试取回一些东西:
$request = Request::all();
$test = Response::json($request);
然后我把这个发给自己看看,结果如下:
object(Illuminate\Http\JsonResponse)#277 (10) {
["jsonOptions":protected]=>
int(0)
["data":protected]=>
string(2) "[]"
["callback":protected]=>
NULL
["encodingOptions":protected]=>
int(15)
["headers"]=>
object(Symfony\Component\HttpFoundation\ResponseHeaderBag)#332 (5) {
["computedCacheControl":protected]=>
array(1) {
["no-cache"]=>
bool(true)
}
["cookies":protected]=>
array(0) {
}
["headerNames":protected]=>
array(3) {
["cache-control"]=>
string(13) "Cache-Control"
["date"]=>
string(4) "Date"
["content-type"]=>
string(12) "Content-Type"
}
["headers":protected]=>
array(3) {
["cache-control"]=>
array(1) {
[0]=>
string(8) "no-cache"
}
["date"]=>
array(1) {
[0]=>
string(29) "Thu, 22 Jun 2017 04:51:13 GMT"
}
["content-type"]=>
array(1) {
[0]=>
string(16) "application/json"
}
}
["cacheControl":protected]=>
array(0) {
}
}
["content":protected]=>
string(2) "[]"
["version":protected]=>
string(3) "1.0"
["statusCode":protected]=>
int(200)
["statusText":protected]=>
string(2) "OK"
["charset":protected]=>
NULL
}
没有“Body Parameter”没有“Payload”变量。我真的很困惑。任何帮助将不胜感激。
【问题讨论】:
标签: laravel laravel-4 slack-api