Created
January 26, 2016 10:26
-
-
Save nczz/4855343b3c7b278f5dd4 to your computer and use it in GitHub Desktop.
簡訊王 API 範例
This file contains 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 | |
function sms_api($username,$password,$dest_addr,$text_str){ | |
$api_host = 'http://202.39.48.216/kotsmsapi-1.php'; | |
if ( $text_str=='' || !preg_match("/^[0-9]{10}$/", $dest_addr) || $username=='' || $password=='' ){ | |
return 'ERROR Params.'; | |
} | |
$data = array( | |
'username'=>$username, | |
'password'=>$password, | |
'dstaddr'=>$dest_addr, | |
'smbody'=>iconv("UTF-8","big5//TRANSLIT",$text_str)); | |
$querystring = http_build_query($data); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "$api_host?$querystring"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment