Created
July 4, 2017 14:54
-
-
Save ammarfaizi2/c6e138a04ae142a559fa5892f240949f 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 | |
/** | |
* @author Ammar Faizi <[email protected]> | |
* @license MIT | |
* @package - | |
* @version 0 | |
*/ | |
class AClass | |
{ | |
/** | |
* @param string $url | |
* @param array $post | |
*/ | |
public function __invoke($url, $post) | |
{ | |
$out = $this->execute($url, $post); | |
printf($out); | |
} | |
/** | |
* Execute | |
* @param string $url | |
* @param string|array $post | |
* @param arrray $opt | |
* @return string | |
*/ | |
private function execute($url, $post = null, $opt = null) | |
{ | |
$ch = curl_init($url); | |
$op = array( | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_SSL_VERIFYPEER => false, | |
CURLOPT_SSL_VERIFYHOST => false, | |
); | |
if (is_array($opt)) { | |
foreach ($opt as $key => $value) { | |
$op[$key] = $value; | |
} | |
} | |
if ($post) { | |
$op[CURLOPT_POST] = true; | |
$op[CURLOPT_POSTFIELDS] = http_build_query($post); | |
} | |
curl_setopt_array($ch, $op); | |
$out = curl_exec($ch); | |
$err = curl_error($ch) and $out = sprintf("%d : ".$err, curl_errno($ch)); | |
return $out; | |
} | |
} | |
// Contoh pemakaian... | |
$a = new AClass(); | |
$a("http://smsgateway.me/api/v3/messages/send", array( | |
"email" => "[email protected]", // Your username for the site | |
"password" => "passwordmu", // Your password for the site | |
"device" => "", // The ID of device you wish to send the message from | |
"number" => "", // The number to send the message to | |
"message" => "", // The content of the message to be sent | |
"send_at" => "", // Time to send the message in Unix Time format | |
"expires_at" => "" // Time to give up trying to send the message at in Unix Time format | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment