学自アリペイ
- 関数ゲートウェイ($url, $time_out="60") {
- $urlinfo = parse_url($url);
- $errno = "";
- $errstr = "";
- $transports = "";
- if ($urlinfo['scheme'] == "https") {
- $transports = "ssl://";
- $urlinfo['port'] = "443";
- }else{
- $transports = "tcp ://";
- $urlinfo['port'] = "80";
- }
-
- $fp = @fsockopen($transports.$urlinfo['host'], $urlinfo['port'], $errno, $errstr, $time_out);
- if (!$fp) {
- die("ERROR: $errno - $errstr
n");
- }else{
- fputs($fp, "POST ".$ urlinfo['path']." HTTP/1.1rn");
- fputs($fp, "ホスト: ".$urlinfo['host']."rn");
- fputs($fp, "コンテンツ タイプ: application/x-www-form-urlencodedrn");
- fputs($fp, "Content-length: ".strlen($urlinfo['query'])."rn");
- fputs($fp, "接続: closenrn");
- fputs($fp, $urlinfo['query']."rnrn");
- while(!feof($fp)) {
- $info[]=@fgets($fp, 1024);
- }
- fclose($fp);
- $info = implode(",", $info);
-
- var_dump($info);
- }
- }
复制代
|