| Conditions | 3 |
| Paths | 4 |
| Total Lines | 23 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| 1 | <?php |
||
| 17 | public static function request($method, $url, $data = null, $timeout = 2) |
||
| 18 | { |
||
| 19 | $options = array( |
||
| 20 | 'http' => array( |
||
| 21 | 'timeout' => $timeout, |
||
| 22 | 'method' => $method, |
||
| 23 | 'header' => "User-Agent: Bouncer Http\r\n" |
||
| 24 | ) |
||
| 25 | ); |
||
| 26 | if ($data) { |
||
| 27 | $content = json_encode($data); |
||
| 28 | $length = strlen($content); |
||
| 29 | $options['http']['header'] .= "Content-Type: application/json\r\n"; |
||
| 30 | $options['http']['header'] .= "Content-Length: {$length}\r\n"; |
||
| 31 | $options['http']['content'] = $content; |
||
| 32 | } |
||
| 33 | $context = stream_context_create($options); |
||
| 34 | $result = @file_get_contents($url, false, $context); |
||
| 35 | if ($result) { |
||
| 36 | $response = json_decode($result, true); |
||
| 37 | return $response; |
||
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 47 |