数日前、paypal からの IPN メッセージの受信が突然停止しました。私は以下のコードを書きました
$url_parsed=parse_url('https://www.sandbox.paypal.com/cgi-bin/webscr');
$post_string = '';
foreach ($_POST as $field=>$value) {
$post_string .= $field.'='.urlencode(stripslashes($value)).'&';
}
$post_string.="cmd=_notify-validate";
$fp = fsockopen($url_parsed['host'],"80",$err_num,$err_str,30);
$myFile = "testpaypal.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $post_string;
fwrite($fh, $stringData);
fwrite($fh, "------------");
if(!$fp){
return false;
} else {
fputs($fp, "POST $url_parsed[path] HTTP/1.0\r\n");
fputs($fp, "Host: $url_parsed[host]\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($post_string)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $post_string . "\r\n\r\n");
while(!feof($fp))
{
$ipn_response .= fgets($fp, 1024);
}
fclose($fp);
if (eregi("VERIFIED",$ipn_response)) {
fwrite($fh, "VERIFIED");
return true;
} else {
fwrite($fh, "UNVERIFIED");
return false;
}
}
fclose($fh);
このコードは、「fclose($fp);」の後に $ipn_response を出力するときと同様に、 err_num を「 0 」に返します。「HTTP/1.0 302 Found Location: https://www.sandbox.paypal.com Server: BigIP Connection: close Content-Length: 0」と表示される行
しかし、$ipn_respnse で「VERIFIED」を取得できません。
「ssl://sandbox.paypal.com」で解析URLを変更するなど、考えられるすべての方法と、Webで提案されている他のすべてのソリューションを試しました。
私は過去 3 日間、この問題で立ち往生しています。だから、私を助けてください。
前もって感謝します。