You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
3.1 KiB

8 years ago
8 years ago
  1. # Telegraph
  2. Telegraph is an API for sending [Webmentions](http://webmention.net).
  3. ## Send a webmention to a specific page
  4. Post to `https://telegraph.p3k.io/webmention`
  5. * `token` - your API key obtained after signing up
  6. * `source` - the URL of your post
  7. * `target` - the URL you linked to
  8. * `callback` - (optional) - a URL that will receive a web hook when new information about this webmention is available
  9. The Telegraph API will validate the parameters and then queue the webmention for sending. If there was a problem with the request, you will get an error response immediately.
  10. The API will first make an HTTP request to the source URL, and look for a link to the target on the page. This happens synchronously so you will get this error reply immediately.
  11. #### Errors
  12. * `missing_parameters` - one or more of the three parameters were not in the request
  13. * `invalid_parameter` - one or more of the parameters were invalid, e.g. the target was not a valid URL
  14. * `no_link_found` - the link to the target URL was not found on the source document
  15. An error response in this case will be returned with an HTTP 400 status code an a JSON body:
  16. ```json
  17. HTTP/1.1 400 Bad Request
  18. Content-type: application/json
  19. {
  20. "error": "missing_parameters",
  21. "error_description": "The source or target parameters were missing"
  22. }
  23. ```
  24. #### Success
  25. If the initial validation succeeds, Telegraph will queue the webmention for sending and return a success response, including a URL you can check for status updates. This URL will be returned even if you also provide a callback URL. The URL will be available in both the `Location` header as well as in the JSON response.
  26. ```
  27. HTTP/1.1 201 Created
  28. Content-type: application/json
  29. Location: https://telegraph.p3k.io/webmention/xxxxxxxx
  30. {
  31. "result": "queued",
  32. "status": "https://telegraph.p3k.io/webmention/xxxxxxxx"
  33. }
  34. ```
  35. ### Callback Events
  36. After Telegraph processes your request, you will receive a post to the callback URL. The initial callback you receive will be one of the following status codes:
  37. * `not_supported` - no webmention or pingback endpoint found
  38. * `webmention_queued` - webmention was queued for processing
  39. * `webmention_success` - webmention was successfully processed (for webmention endpoints which process synchronously)
  40. * `webmention_error` - the webmention endpoint returned an error code
  41. * `pingback_success` - pingback was received (pingback does not differentiate between when a request is queued or processed immediately)
  42. * `pingback_error` - the pingback endpoint returned an error code
  43. Typically, webmention endpoints defer processing until later, so normally the first callback received will indicate that the webmention was queued. This callback will normally be sent relatively quickly after you make the initial request, typically within a few seconds.
  44. If the webmention endpoint provides status updates, either through a status URL or web hook, then Telegraph will deliver follow-up notifications when it gets updated information.
  45. A callback from Telegraph will include the following post body parameters:
  46. * `source` - the URL of your post
  47. * `target` - the URL you linked to
  48. * `code` - one of the status codes above, e.g. `webmention_queued`