<?php
// Note: request params
$request_phone_number = '080********';
$request_sms_text = 'Any text';
// Note: api host params
// TODO replace values
$api_host = "www.***.jp";
$api_username = 'your_user_name';
$api_password = 'your_password';
$api_prefix = "https://${api_host}/api/";
$request_params = array(
'username' => $api_username,
'password' => $api_password,
'mobilenumber' => $request_phone_number,
'smstext' => $request_sms_text,
);
$api_url = $api_prefix;
// Note: Don't change the following line
$request_post_boundary_delimiter = str_pad(uniqid(), 38, '-', STR_PAD_LEFT);
$request_post_content = '';
foreach ($request_params as $name => $content) {
$request_post_content .= "--" . $request_post_boundary_delimiter . "\r\n"
. 'Content-Disposition: form-data; name="' . $name . '"' . "\r\n\r\n"
. $content . "\r\n";
}
$request_post_content .= "--" . $request_post_boundary_delimiter . "--" . "\r\n";
$api_request_opts = array(
'http' => array(
'method' => 'POST',
'header' => array(
'Accept: text/html, */*; q=0.01',
'Content-Type: multipart/form-data; boundary=' . $request_post_boundary_delimiter,
),
'content' => $request_post_content,
)
);
$api_request_context = stream_context_create($api_request_opts);
$result_content = @file_get_contents($api_url, FALSE, $api_request_context);
if ($result_content === FALSE) {
// possible disabled by php config - not API issue
echo 'ERROR: Cannot do the HTTP request';
return;
}
// Note: the first line contains the result code
$result_code_as_integer = intval(preg_split('#\r?\n#', $result_content, 2)[0]);
$success = $result_code_as_integer === 200;
echo "Success: " . ($success ? 'True' : 'FALSE') . "\r\n";
echo "Result Code: " . $result_code_as_integer . "\r\n";
その他の言語についてもお問い合わせください。