This shows you the differences between two versions of the page.
invio_php_http_get [2020/08/01 23:02] |
invio_php_http_get [2023/12/29 14:29] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== invio PHP HTTP GET ====== | ||
+ | ==== 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 GET require curl compiled inside PHP | ||
+ | //DEFAULT CHOICE | ||
+ | |||
+ | |||
+ | function get_url( $url, $javascript_loop = 0, $timeout = 5 ) | ||
+ | { | ||
+ | $url = str_replace( "& | ||
+ | $cookie = tempnam ("/ | ||
+ | $ch = curl_init(); | ||
+ | curl_setopt( $ch, CURLOPT_USERAGENT, | ||
+ | curl_setopt( $ch, CURLOPT_URL, | ||
+ | curl_setopt( $ch, CURLOPT_COOKIEJAR, | ||
+ | |||
+ | curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, | ||
+ | |||
+ | curl_setopt( $ch, CURLOPT_ENCODING, | ||
+ | |||
+ | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, | ||
+ | |||
+ | curl_setopt( $ch, CURLOPT_AUTOREFERER, | ||
+ | |||
+ | curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, | ||
+ | |||
+ | curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, | ||
+ | |||
+ | curl_setopt( $ch, CURLOPT_TIMEOUT, | ||
+ | |||
+ | curl_setopt( $ch, CURLOPT_MAXREDIRS, | ||
+ | |||
+ | $content = curl_exec( $ch ); | ||
+ | |||
+ | $response = curl_getinfo( $ch ); | ||
+ | |||
+ | curl_close ( $ch ); | ||
+ | |||
+ | |||
+ | if ($response[' | ||
+ | |||
+ | { | ||
+ | |||
+ | ini_set(" | ||
+ | |||
+ | |||
+ | |||
+ | if ( $headers = get_headers($response[' | ||
+ | |||
+ | { | ||
+ | |||
+ | foreach( $headers as $value ) | ||
+ | |||
+ | { | ||
+ | |||
+ | if ( substr( strtolower($value), | ||
+ | |||
+ | return get_url( trim( substr( $value, 9, strlen($value) ) ) ); | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | |||
+ | if ( ( preg_match("/> | ||
+ | |||
+ | $javascript_loop < 5 | ||
+ | |||
+ | ) | ||
+ | |||
+ | { | ||
+ | |||
+ | return get_url( $value[1], $javascript_loop+1 ); | ||
+ | |||
+ | } | ||
+ | |||
+ | else | ||
+ | |||
+ | { | ||
+ | |||
+ | return $content; | ||
+ | |||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | $url = ' | ||
+ | |||
+ | $response = get_url($url); | ||
+ | |||
+ | echo $response; | ||
+ | |||
+ | ?> | ||
+ | </ |