forked from junaidbhura/composer-wp-pro-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Http.php
39 lines (34 loc) · 933 Bytes
/
Http.php
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
<?php
/**
* Http Wrapper.
*
* @package Junaidbhura\Composer\WPProPlugins
*/
namespace Junaidbhura\Composer\WPProPlugins;
/**
* Http class.
*/
class Http {
/**
* POST request.
*
* @param string $url Url to POST.
* @param array $args Arguments to POST.
* @return mixed
*/
public function post( $url = '', $args = array() ) {
$curl_handle = curl_init();
curl_setopt( $curl_handle, CURLOPT_URL, $url );
curl_setopt( $curl_handle, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl_handle, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $curl_handle, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $curl_handle, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $curl_handle, CURLOPT_CUSTOMREQUEST, 'POST' );
if ( ! empty( $args ) ) {
curl_setopt( $curl_handle, CURLOPT_POSTFIELDS, http_build_query( $args ) );
}
$response = curl_exec( $curl_handle );
curl_close( $curl_handle );
return $response;
}
}