Skip to content

Instantly share code, notes, and snippets.

@nathanielks
Last active March 14, 2023 23:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanielks/10927893 to your computer and use it in GitHub Desktop.
Save nathanielks/10927893 to your computer and use it in GitHub Desktop.
Script used to redirect webhook request from localhost to a local domain
<?php
// Props to goddva: http://stackoverflow.com/questions/1361169/possible-to-add-data-to-the-body-of-a-http-request-using-curl-in-php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://site.dev/webhooks.php?type=stripe");
curl_setopt($ch, CURLOPT_USERAGENT, "My user agent");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('php://input') );
$output = curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment