英文:
Trying to send a request to Google WebSub by getting error hub.mode invalid
问题
我正在尝试使用以下代码发布更新到 WeSub,但我遇到错误
> hub.mode 无效
function sendWebSubNotification($topicUrl) {
$response = Http::post("https://pubsubhubbub.appspot.com/", [
'hub.mode' => 'publish',
'hub.url' => $topicUrl,
], [
'Content-Type' => 'application/x-www-form-urlencoded'
]);
echo $response->getBody();
if ($response->ok()) {
// Ping successful
return true;
} else {
// Ping failed
return false;
}
}
英文:
I am trying to post an update to WeSub using the following code but I am getting the error
> hub.mode invalid
function sendWebSubNotification($topicUrl) {
$response = Http::post("https://pubsubhubbub.appspot.com/", [
'hub.mode' => 'publish',
'hub.url' => $topicUrl,
], [
'Content-Type' => 'application/x-www-form-urlencoded'
]);
echo $response->getBody();
if ($response->ok()) {
// Ping successful
return true;
} else {
// Ping failed
return false;
}
}
答案1
得分: 1
使用 asForm() 在 Laravel 中发送 URL 编码的 POST 请求:
$response = Http::asForm()->post("https://pubsubhubbub.appspot.com/", [
'hub.mode' => 'publish',
'hub.url' => $topicUrl,
]);
英文:
Use asForm() for sending URL encoded POST requests in Laravel:
$response = Http::asForm()->post("https://pubsubhubbub.appspot.com/", [
'hub.mode' => 'publish',
'hub.url' => $topicUrl,
]);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论