Simple PHP script to send EIR SMS texts via Eir website
The code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | <!--?php $cookie_file = "cookie.txt"; $eir_username = "xxx@xxx.com"; $eir_password = "QWERTYUIOP"; $mynumber = "+353861112222"; $recipient "$mynumber"; $message = "simple text message"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://my.eir.ie/login"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36'); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); curl_exec($ch); curl_close($ch); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://my.eir.ie/rest/brand/3/portalUser/authenticate"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"emailAddress\":\"" . $eir_username . "\",\"password\":\"" . $eir_password . "\"}"); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json' ) ); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); curl_exec($ch); curl_close($ch); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://my.eir.ie/mobile/webtext/mobileNumbers/" . $mynumber . "/messages?ts=" . time() ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"content\":\"" . $message . "\",\"recipients\":[\"" . $recipient . "\"]}"); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type:application/json' ) ); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); curl_exec($ch); curl_close($ch); </pre--> |