Strava webhook event data not receive

85 Views Asked by At

I am working on project PHP need strava webhook to update strava user data any time their activity change. I am official document for webhook here https://developers.strava.com/docs/webhooks/ I follow this code https://gist.github.com/erikdmitchell/2e165c57e618de14e1b208fceba2ee65 and make webhook call well to webhook.php

And this is my PHP code on webhook.php to receive the call from strava

$html = "";
$html = $html . '<hr/>' . json_encode($_GET) . '<hr/>' . json_encode($_POST) . '<hr/>' . json_encode($_REQUEST);

And my output for all of receive call from Strava

<hr/>[]<hr/>[]<hr/>[]

My problem is I tried many ways but can't get Event Data from strava webhook send to me. From my webhook.php file when Strava call to it, I don't see any more information from $_GET, $_POST or $_REQUEST

At least I need which user id has just add/delete/update their activity on strava

Welcome any of your solution...

1

There are 1 best solutions below

1
On BEST ANSWER

Right at the bottom of the Strava documentation they show how to send a test event to your own webhook with curl. They show POSTing a JSON body with Content-Type: application/json. That means it is not application/x-www-form-urlencoded, so there is no $_POST, and your webhook will need to work with the raw request body.

To do that, try something like this:

$payload = file_get_contents('php://input');
$json = json_decode($payload, true);

// See what it looks like
print_r($json);

References: