This shows you the differences between two versions of the page.
|
invio_php_http_post [2020/08/01 23:02] |
invio_php_http_post [2023/12/29 14:29] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== invio PHP HTTP POST ====== | ||
| + | ==== Esempio API ==== | ||
| + | < | ||
| + | <? | ||
| + | |||
| + | ////////////////// | ||
| + | //PURPOSE: SEND SMS USING KDEV GATEWAY // | ||
| + | //AUTHOR: Davide Cantaluppi < | ||
| + | //V2-Rev. 0 // | ||
| + | //PLATFORM: Not platform dependent // | ||
| + | //DEPEND: PHP >4.1.2; libcurl extension // | ||
| + | // Secured SSL // | ||
| + | //Keep parameters in a safe place // | ||
| + | ////////////////// | ||
| + | |||
| + | //OUTPUT of the call | ||
| + | // | ||
| + | |||
| + | // | ||
| + | |||
| + | $username=" | ||
| + | $password=" | ||
| + | $to=" | ||
| + | $text=" | ||
| + | |||
| + | //function for send.php call in POST require curl compiled inside PHP | ||
| + | //DEFAULT CHOICE | ||
| + | |||
| + | |||
| + | function do_post_request($url, | ||
| + | $params = array(' | ||
| + | ' | ||
| + | ' | ||
| + | )); | ||
| + | if ($optional_headers !== null) { | ||
| + | $params[' | ||
| + | } | ||
| + | $ctx = stream_context_create($params); | ||
| + | $fp = @fopen($url, | ||
| + | if (!$fp) { | ||
| + | throw new Exception(" | ||
| + | } | ||
| + | $response = @stream_get_contents($fp); | ||
| + | if ($response === false) { | ||
| + | throw new Exception(" | ||
| + | } | ||
| + | return $response; | ||
| + | } | ||
| + | $urlPost=' | ||
| + | $params=' | ||
| + | $response=do_post_request($urlPost, | ||
| + | |||
| + | echo $response; | ||
| + | |||
| + | ?> | ||
| + | </ | ||