无法从 webhook 获得回调 laravel
Cant get callback from webhook laravel
我正在尝试为基于 API 的订阅创建一个 webhook,它会在物联网设备发生变化时向我发送 JSON 数据。我似乎无法启动该功能,而且我无法弄清楚背后的原因。
API给我的数据如下:
{"data:{"type":1,"value":1,"dev_id":5,"attr_id":0},
"ack":"ok","action":"upload","mac":"C8EEA63070CF"}
我的 webhook 函数:
class webHookController extends Controller
{
public function webhook(Request $request)
{
$options = array(
'cluster' => 'ap2',
'useTLS' => true
);
$pusher = new \Pusher\Pusher(
'cant',
'show',
'these',
$options
);
$pusher->trigger("n-channel", 'n-event',$request['data']);
$thinker = t::where('thinker_MAC',$request['mac'])->first();
$slave = sd::where('connected_thinker_MAC',$request['mac'])->get();
if(count($slave) > 0 && $thinker->user_id != NULL)
{
$pusher->trigger($u->id."-channel", 'n-event',$request);
}
else
{
}
return "hooked";
}
}
我在api.php的路线:
Route::post('/webhook','webHookController@webhook');
证明订阅有效:
我还添加了忽略 csrf 令牌的路由。
protected $except = [
'/webhook',
];
如果我使用邮递员,我可以运行我的功能。任何帮助将不胜感激。
事情执行得很完美。只需要使用 ngrok 进行测试。为前来寻找相同问题答案的人解答。好像这里没有人知道答案。
我正在尝试为基于 API 的订阅创建一个 webhook,它会在物联网设备发生变化时向我发送 JSON 数据。我似乎无法启动该功能,而且我无法弄清楚背后的原因。
API给我的数据如下:
{"data:{"type":1,"value":1,"dev_id":5,"attr_id":0}, "ack":"ok","action":"upload","mac":"C8EEA63070CF"}
我的 webhook 函数:
class webHookController extends Controller
{
public function webhook(Request $request)
{
$options = array(
'cluster' => 'ap2',
'useTLS' => true
);
$pusher = new \Pusher\Pusher(
'cant',
'show',
'these',
$options
);
$pusher->trigger("n-channel", 'n-event',$request['data']);
$thinker = t::where('thinker_MAC',$request['mac'])->first();
$slave = sd::where('connected_thinker_MAC',$request['mac'])->get();
if(count($slave) > 0 && $thinker->user_id != NULL)
{
$pusher->trigger($u->id."-channel", 'n-event',$request);
}
else
{
}
return "hooked";
}
}
我在api.php的路线:
Route::post('/webhook','webHookController@webhook');
证明订阅有效:
我还添加了忽略 csrf 令牌的路由。
protected $except = [
'/webhook',
];
如果我使用邮递员,我可以运行我的功能。任何帮助将不胜感激。
事情执行得很完美。只需要使用 ngrok 进行测试。为前来寻找相同问题答案的人解答。好像这里没有人知道答案。