webhook subscription php

342 views
Skip to first unread message

Luca Novali

unread,
Nov 11, 2021, 1:23:45 AM11/11/21
to Strava API
Goodmorning, I'm trying to develop a webhook subscription following strava official guide at https://developers.strava.com/docs/webhooks/.
My subscription creation request is like this:

      -F client_id=xxxxx \
      -F client_secret=xxxxxxxxxxxxxxxxxxx \
      -F 'verify_token=STRAVA'

but I get this result

"{\"message\":\"Bad Request\",\"errors\":[{\"resource\":\"PushSubscription\",\"field\":\"callback url\",\"code\":\"not verifiable\"}]}"

Obviously I tested my callback url and it's valid

I try this curl command both in php and in linux shell, but the result is the same

What am I doing wrong?

Serhii Tsarikovskyi

unread,
Nov 11, 2021, 3:31:23 AM11/11/21
to Strava API
Hi, 
Do you return 200?

Luca Novali

unread,
Nov 11, 2021, 4:34:07 AM11/11/21
to Strava API
I get this json message
"{\"message\":\"Bad Request\",\"errors\":[{\"resource\":\"PushSubscription\",\"field\":\"callback url\",\"code\":\"not verifiable\"}]}"
I suppose it's not 200...

Serhii Tsarikovskyi

unread,
Nov 11, 2021, 6:47:22 AM11/11/21
to Strava API
your callback URL https://myurl.com/strava/webhookListener.php' should return 200 

Vojtěch Hlaváček

unread,
Nov 11, 2021, 9:41:37 AM11/11/21
to Serhii Tsarikovskyi, Strava API
I put a callback url: https://virtualni-challenge-vh-3900225-strava.webovy-servis.com/ping-strava-activities it returns 200 but it is still the same.

čt 11. 11. 2021 v 12:47 odesílatel Serhii Tsarikovskyi <serhii.ts...@reface.ai> napsal:
--
You received this message because you are subscribed to the Google Groups "Strava API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to strava-api+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/strava-api/2a34591b-405d-4036-a49c-bfd40d6a51a7n%40googlegroups.com.


--
Vojtěch Hlaváček


Ben Coomes

unread,
Nov 14, 2021, 5:51:43 PM11/14/21
to Strava API
Hi  Vojtěch,

In addition to returning 200, your application must also respond with the expected payload within 2 seconds.

Strava will send a GET request to your subscription endpoint with a query parameter named 'hub.challenge'. Your application must return a response which includes the value of that parameter in the format indicated by the docs. Note that the content type header of your response must also be set to 'application/json'. 

I hope this helps, 
Ben
Message has been deleted

Luca Novali

unread,
Jan 3, 2022, 1:44:22 AM1/3/22
to Strava API
Goodmorning, I suppose finally I've completed a webhook subscription and I have an id like this  "{\"id\":xxxxxx}"
I was able also delete this subscription (but I still problems with "view subscription" method).
Anyway, at the moment the main question is: what I need to do with this subscrition id?
I really completed the webhook subscription process?
Now should I receive some messages from Strava when my Strava user upload a new activity?
In which page strava should send my activity? I'm sorry for these question but official documentation is not exaustive.
thanks a lot


Ben Coomes

unread,
Jan 4, 2022, 9:07:29 PM1/4/22
to Strava API
I haven't found a great use for the subscription ID yet. You don't need it to receive events. 

Once you've created a subscription successfully, an event will be sent to the endpoint you specified whenever a Strava user who has authorized your application uploads or modifies an activity. So, even for you, you must authorize your application so that it appears in the 'My Apps' section of your profile.

Note that if you delete your subscription, you won't get any events. In that case, you can create a new one again.

Luca Novali

unread,
Jan 5, 2022, 2:30:32 AM1/5/22
to Ben Coomes, Strava API
Hello Ben!
Excuse me but I'll try to analyze your answer to ensure I've understand your words:
" Once you've created a subscription successfully, an event will be sent to the endpoint you specified whenever a Strava user who has authorized your application uploads or modifies an activity. So, even for you, you must authorize your application so that it appears in the 'My Apps' section of your profile."

"Once you've created a subscription successfully": if I have a subscription ID, I suppose I've created a subscription successfully. isn't it?
"an event will be sent to the endpoint you specified": endpoint is the url I've specified when I created the subscription? How can I receive these events? I suppose I should receive a json text. I have a php page. Following syntax is correct? $json = file_get_contents('php://input');
" whenever a Strava user who has authorized your application uploads or modifies an activity.": I authorized strava and I need to get activities. I don't want to upload or modify existing activities. I only need to receive running or cycling activities data with the entire set of informations (gps track points, hr, power, laps, segments,...)

Thank you so much.


You received this message because you are subscribed to a topic in the Google Groups "Strava API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/strava-api/IpLBdvJly6U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to strava-api+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/strava-api/8b266db0-6a5a-4a88-b2ec-38026fd23c82n%40googlegroups.com.

Ben Coomes

unread,
Jan 5, 2022, 8:23:03 AM1/5/22
to Strava API
Sure thing! I think you understand correctly. 


"How can I receive these events? I suppose I should receive a json text. I have a php page. Following syntax is correct? $json = file_get_contents('php://input');"
  Strava will POST to the URL you set when creating the subscription. So, if that URL is https://myStravaApp.com/callback.php, then Strava will POST to that URL and the body will be something like
{ "aspect_type": "update", "event_time": 1516126040, "object_id": 1360128428, "object_type": "activity", "owner_id": 134815, "subscription_id": 120475, "updates": { "title": "Messy" } }. See https://developers.strava.com/docs/webhooks/.
Using the example above, you could then send a subsequent request to get the details for the activity with ID of 1360128428.


 I authorized strava and I need to get activities. I don't want to upload or modify existing activities. I only need to receive running or cycling activities data with the entire set of informations (gps track points, hr, power, laps, segments,...)
If getting details on existing activities is your goal, then a subscription might not be the best match for your app. Subscriptions are helpful for when you want your app to take some action for every new (or modified) activity, for example, to set a weather report in the description. For getting existing activities, I would look at calling the API directly. You can call /athlete/activities to get a list of activities. The athlete for which the request will return results is based on the access token you pass in the request. Then, you can call /activities/{id} to get the details for a single activity by the activity ID. You don't need a subscription for either of those calls, only an access token.
Reply all
Reply to author
Forward
0 new messages