Advertisement
Guest User

Untitled

a guest
Jan 21st, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. //======== Simple PHP code sample ==========//
  2.  
  3. /*
  4. * This example requires allow_url_fopen to be enabled in php.ini.
  5. * If it is not enabled, file_get_contents()
  6. * will return an empty result.
  7. *
  8. * We recommend that you use port 5567 instead of port 80, but your
  9. * firewall will probably block access to this port (see FAQ for more
  10. * details):
  11. * $url = http://nettyhost.com/smsapi/TR/sendmsg.aspx?;
  12. *
  13. * Please note that this is only for illustrative purposes,
  14. * we strongly recommend that you use our comprehensive example
  15. */
  16. $url = http://nettyhost.com/smsapi/TR/sendmsg.aspx?';
  17. $data = 'username=your_username&password=your_password&message='.urlencode('Testing SMS').'&mobile='.urlencode($msisdn).'&sendername=TESTSN';
  18.  
  19. $response = do_post_request($url, $data);
  20.  
  21. print $response;
  22.  
  23. function do_post_request($url, $data, $optional_headers = 'Content-type:application/x-www-form-urlencoded') {
  24. $params = array('http' => array(
  25. 'method' => 'POST',
  26. 'content' => $data,
  27. ));
  28. if ($optional_headers !== null) {
  29. $params['http']['header'] = $optional_headers;
  30. }
  31.  
  32. $ctx = stream_context_create($params);
  33.  
  34.  
  35. $response = @file_get_contents($url, false, $ctx);
  36. if ($response === false) {
  37. print "Problem reading data from $url, No status returnedn";
  38. }
  39.  
  40. return $response;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement