Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
960 B
4
Indexable
Never

<?php
function connect($end_point, $post) {
	$_post = array();
	if (is_array($post)) {
		foreach ($post as $name => $value) {
			$_post[] = $name.'='.urlencode($value);
		}
	}
	$ch = curl_init($end_point);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	if (is_array($post)) {
		curl_setopt($ch, CURLOPT_POSTFIELDS, join('&', $_post));
	}
	curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)');
	$result = curl_exec($ch);
	if (curl_errno($ch) != 0 && empty($result)) {
		$result = false;
	}
	curl_close($ch);
	return $result;
}

$api_url = 'https://neopay.id/api/mutation';
$post_data = array(
	'access_token'     => 'cklYMXZWNkhjUWdnNWRUSDE2TnI3QT09',
    'subscription_key' => '51PA-ZANT-JEZC-B8GK',
);

$api = json_decode(connect($api_url, $post_data));
print("<pre>".print_r($api,true)."</pre>");