{"id":1197,"date":"2024-04-04T18:10:25","date_gmt":"2024-04-04T09:10:25","guid":{"rendered":"https:\/\/test.media-sms.net\/api_st\/?p=1197"},"modified":"2024-05-09T12:41:45","modified_gmt":"2024-05-09T03:41:45","slug":"single-php","status":"publish","type":"post","link":"https:\/\/media-sms.net\/developer\/console\/con-sample\/single-php\/","title":{"rendered":"\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u500b\u5225\u65b9\u5f0fPHP"},"content":{"rendered":"\n<pre class=\"wp-block-code code-design-01\" style=\"font-size:16px\"><code>&lt;?php\n\n\/\/ Note: request params\n$request_phone_number = '080********';\n$request_sms_text = 'Any text';\n\n\/\/ Note: api host params\n\/\/ TODO replace values\n$api_host = \"www.***.jp\";\n$api_username = 'your_user_name';\n$api_password = 'your_password';\n\n$api_prefix = \"https:\/\/${api_host}\/api\/\";\n\n$request_params = array(\n    'username' =&gt; $api_username,\n    'password' =&gt; $api_password,\n\n    'mobilenumber' =&gt; $request_phone_number,\n    'smstext' =&gt; $request_sms_text,\n);\n\n$api_url = $api_prefix;\n\n\/\/ Note: Don't change the following line\n$request_post_boundary_delimiter = str_pad(uniqid(), 38, '-', STR_PAD_LEFT);\n\n$request_post_content = '';\nforeach ($request_params as $name =&gt; $content) {\n    $request_post_content .= \"--\" . $request_post_boundary_delimiter . \"\\r\\n\"\n        . 'Content-Disposition: form-data; name=\"' . $name . '\"' . \"\\r\\n\\r\\n\"\n        . $content . \"\\r\\n\";\n}\n$request_post_content .= \"--\" . $request_post_boundary_delimiter . \"--\" . \"\\r\\n\";\n\n$api_request_opts = array(\n    'http' =&gt; array(\n        'method' =&gt; 'POST',\n        'header' =&gt; array(\n            'Accept: text\/html, *\/*; q=0.01',\n            'Content-Type: multipart\/form-data; boundary=' . $request_post_boundary_delimiter,\n        ),\n        'content' =&gt; $request_post_content,\n    )\n);\n\n$api_request_context = stream_context_create($api_request_opts);\n\n$result_content = @file_get_contents($api_url, FALSE, $api_request_context);\n\nif ($result_content === FALSE) {\n    \/\/ possible disabled by php config - not API issue\n    echo 'ERROR: Cannot do the HTTP request';\n\n    return;\n}\n\n\/\/ Note: the first line contains the result code\n$result_code_as_integer = intval(preg_split('#\\r?\\n#', $result_content, 2)&#91;0]);\n\n$success = $result_code_as_integer === 200;\n\necho \"Success: \" . ($success ? 'True' : 'FALSE') . \"\\r\\n\";\necho \"Result Code: \" . $result_code_as_integer . \"\\r\\n\";<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u305d\u306e\u4ed6\u306e\u8a00\u8a9e\u306b\u3064\u3044\u3066\u3082\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>\u305d\u306e\u4ed6\u306e\u8a00\u8a9e\u306b\u3064\u3044\u3066\u3082\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"_links":{"self":[{"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/posts\/1197"}],"collection":[{"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/comments?post=1197"}],"version-history":[{"count":5,"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/posts\/1197\/revisions"}],"predecessor-version":[{"id":1510,"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/posts\/1197\/revisions\/1510"}],"wp:attachment":[{"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/media?parent=1197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/categories?post=1197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/media-sms.net\/developer\/wp-json\/wp\/v2\/tags?post=1197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}