Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trying to send a request to Google WebSub by getting error hub.mode invalid

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;
    }

}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use asForm() for sending URL encoded POST requests in Laravel:

$response = Http::asForm()->post("https://pubsubhubbub.appspot.com/", [
    'hub.mode' => 'publish',
    'hub.url' => $topicUrl,
]);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading