Created
November 13, 2017 17:55
-
-
Save StancuFlorin/1449c11ec6793f23b79529e0da82fc62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $token = $_GET['t']; | |
| if ($token !== "C7Ck9o4Fpi1Yh7YTCtk0") { | |
| print_r("You need to specify the correct token."); | |
| exit(); | |
| } | |
| $data = json_decode(file_get_contents('php://input'), true); | |
| $url = $data['url']; | |
| $method = $data['method']; | |
| if (empty($url) || empty($url)) { | |
| print_r("You need to specify the URL and the HTTP method."); | |
| exit(); | |
| } | |
| $body = null; | |
| if (!empty($data['body'])) { | |
| $body = json_encode($data['body']); | |
| } | |
| $headers = "Content-Type: application/json"; | |
| if (!empty($data['headers'])) { | |
| foreach ($data['headers'] as &$header) { | |
| $headers = $headers . "\r\n" . $header['name'] . ": " . $header['value']; | |
| } | |
| } | |
| print_r("Request Headers\r\n" . $headers . "\r\n"); | |
| print_r("Request URL: " . $url . "\r\n"); | |
| print_r("Request Method: " . $method . "\r\n"); | |
| print_r("Request Body\r\n" . $body . "\r\n"); | |
| $options = array( | |
| 'http' => array( | |
| 'header' => $headers, | |
| 'method' => $method, | |
| 'content' => $body, | |
| 'ignore_errors' => true | |
| ) | |
| ); | |
| $context = stream_context_create($options); | |
| $result = file_get_contents($url, false, $context); | |
| print_r("\r\nResponse Body\r\n" . $result); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.