查看文章 |
使用socket,在线支付
2008-08-29 11:20
$fp = fsockopen ($host, 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br>\n"; } else { $request="POST http://www.westpay.com.cn/pay/ISPN.asp HTTP/1.0 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */ * Referer: http://www.westpay.com.cn Accept-Language: gb2312 Content-Type: application/x-www-form-urlencoded User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt) Host: www.westpay.com.cn Content-Length: $len Proxy-Connection: Keep-Alive Pragma: no-cache $req"; fputs ($fp, "$request"); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { $msg = "支付通知验证成功"; $state= 1; } else if (strcmp ($res, "INVALID") == 0) { $msg = "支付通知验证失败"; $state = 2; } else { $msg = "支付通知验证过程中出现错误"; $state = 3; } } fclose ($fp); }echo($msg); |
最近读者: