Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. function post_async($url, array $params)
  2. {
  3. foreach ($params as $key => &$val) {
  4. if (is_array($val)) $val = implode(',', $val);
  5. $post_params[] = $key.'='.urlencode($val);
  6. }
  7. $post_string = implode('&', $post_params);
  8.  
  9. $parts=parse_url($url);
  10.  
  11. $fp = fsockopen($parts['host'],
  12. isset($parts['port'])?$parts['port']:80,
  13. $errno, $errstr, 30);
  14.  
  15. $out = "POST ".$parts['path']." HTTP/1.1\r\n";
  16. $out.= "Host: ".$parts['host']."\r\n";
  17. $out.= "Content-Type: application/x-www-form-urlencoded\r\n";
  18. $out.= "Content-Length: ".strlen($post_string)."\r\n";
  19. $out.= "Connection: Close\r\n\r\n";
  20. if (isset($post_string)) $out.= $post_string;
  21.  
  22. fwrite($fp, $out);
  23. fclose($fp);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement