-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbroadcast.php
More file actions
59 lines (45 loc) · 1.17 KB
/
Copy pathbroadcast.php
File metadata and controls
59 lines (45 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
// composer
require __DIR__ . '/vendor/autoload.php';
if (!function_exists('getallheaders'))
{
function getallheaders()
{
$headers = [];
foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == 'HTTP_')
{
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}
$headers = getallheaders();
$formData = $_POST ?? [];
$queryParam = $_GET ?? [];
$method = $_SERVER['REQUEST_METHOD'];
$body = file_get_contents('php://input');
function callUrl($method, $url, $headers, $post, $queryParam, $body)
{
if ($queryParam) {
$url .= '?' . http_build_query($queryParam);
}
$client = new \GuzzleHttp\Client([
'header' => $headers
]);
$options = [];
if ($body) {
$options['body'] = $body;
}
if ($post) {
$options['form_params'] = $post;
}
$client->request($method, $url, $options);
}
$broadcastUrl = include(__DIR__ . '/urls.php');
foreach ($broadcastUrl as $url) {
callUrl($method, $url, $headers, $formData, $queryParam, $body);
}
?>