Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php,找不到HTTP_引用程序_Php_E Commerce - Fatal编程技术网

php,找不到HTTP_引用程序

php,找不到HTTP_引用程序,php,e-commerce,Php,E Commerce,您好,我正在尝试连接以将我的表单集成到支付提供商,但我得到的URL不允许,结果是找不到HTTP_REFERER #the following function performs a HTTP Post and returns the whole response function pullpage( $host, $usepath, $postdata = "" ) { # open socket to filehandle(epdq encryption cgi) $fp = fsocko

您好,我正在尝试连接以将我的表单集成到支付提供商,但我得到的URL不允许,结果是找不到HTTP_REFERER

#the following function performs a HTTP Post and returns the whole response
function pullpage( $host, $usepath, $postdata = "" ) {

# open socket to filehandle(epdq encryption cgi)
 $fp = fsockopen( $host, 80, &$errno, &$errstr, 60 );

#check that the socket has been opened successfully
 if( !$fp ) {
    print "$errstr ($errno)<br>\n";
 }
 else {

    #write the data to the encryption cgi
    fputs( $fp, "POST $usepath HTTP/1.0\n");
    $strlength = strlen( $postdata );
    fputs( $fp, "Content-type: application/x-www-form-urlencoded\n" );
    fputs( $fp, "Content-length: ".$strlength."\n\n" );
    fputs( $fp, $postdata."\n\n" );

    #clear the response data
   $output = "";


    #read the response from the remote cgi 
    #while content exists, keep retrieving document in 1K chunks
    while( !feof( $fp ) ) {
        $output .= fgets( $fp, 1024);
    }

    #close the socket connection
    fclose( $fp);
 }

#return the response
 return $output;
}

#define the remote cgi in readiness to call pullpage function 
$server="secure2.epdq.co.uk";
$url="/cgi-bin/CcxBarclaysEpdqEncTool.e";

#the following parameters have been obtained earlier in the merchant's webstore
#clientid, passphrase, oid, currencycode, total
$params="clientid=xxx";
$params.="&password=xxxx";
$params.="&oid=xxxx";
$params.="&chargetype=Auth";
$params.="&currencycode=826";
$params.="&total=120";

#perform the HTTP Post
$response = pullpage( $server,$url,$params );

#split the response into separate lines
$response_lines=explode("\n",$response);

#for each line in the response check for the presence of the string 'epdqdata'
#this line contains the encrypted string
$response_line_count=count($response_lines);
for ($i=0;$i<$response_line_count;$i++){
    if (preg_match('/epdqdata/',$response_lines[$i])){
        $strEPDQ=$response_lines[$i];
    }
}


<FORM action="https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdq.e" method="POST">
<?php print "$strEPDQ"; ?>
<INPUT type="hidden" name="returnurl" value="http://www.xxxxxx.co.uk/test/confirm.php">
<INPUT type="hidden" name="merchantdisplayname" value="xx xxx">
<INPUT type=hidden name=baddr1 value="address line 1">
<INPUT type=hidden name=baddr2 value="address line 2">
<INPUT type=hidden name=baddr3 value="address line 3">
<INPUT type=hidden name=bcity value="City">
<INPUT type=hidden name=bcountyprovince value="County">
<INPUT type=hidden name=bpostalcode value="Postcode">
<INPUT type=hidden name=bcountry value="GB">
<INPUT type=hidden name=btelephonenumber value="01111 012345">
<INPUT type=hidden name=email value="xxxxx">
<INPUT type=hidden name=saddr1 value="Address line 1">
<INPUT type=hidden name=saddr2 value="Address line 2">
<INPUT type=hidden name=saddr3 value="Address line 3">
<INPUT type=hidden name=scity value="City">
<INPUT type=hidden name=scountyprovince value="County">
<INPUT type=hidden name=spostalcode value="Postcode">
<INPUT type=hidden name=scountry value="GB">
<INPUT type=hidden name=stelephonenumber value="01111 012345">
<INPUT TYPE="submit" VALUE="purchase">
</FORM>
以下函数执行HTTP Post并返回整个响应 函数pullpage($host、$usepath、$postdata=”“){ #打开套接字到文件句柄(epdq加密cgi) $fp=fsockopen($host,80,&$errno,&$errstr,60); #检查套接字是否已成功打开 如果(!$fp){ 打印“$errstr($errno)
\n”; } 否则{ #将数据写入加密cgi fputs($fp,“POST$usepath HTTP/1.0\n”); $strlength=strlen($postdata); fputs($fp,“内容类型:application/x-www-form-urlencoded\n”); fputs($fp,“内容长度:.$strlength.\n\n”); fputs($fp,$postdata.\n\n”); #清除响应数据 $output=“”; #从远程cgi读取响应 #当内容存在时,保持以1K块检索文档 而(!feof($fp)){ $output.=fgets($fp,1024); } #关闭插座连接 fclose($fp); } #返回响应 返回$output; } #定义远程cgi以准备调用pullpage函数 $server=“secure2.epdq.co.uk”; $url=“/cgi-bin/CcxBarclaysEpdqEncTool.e”; #以下参数已在商户的网上商店中获得 #客户ID、密码短语、oid、货币代码、总计 $params=“clientid=xxx”; $params.=“&password=xxxx”; $params.=“&oid=xxxx”; $params.=“&chargetype=Auth”; $params.=“¤cycode=826”; $params.=“&total=120”; #执行HTTP Post $response=pullpage($server,$url,$params); #将响应拆分为单独的行 $response\u lines=分解(“\n”,$response); #对于响应中的每一行,检查是否存在字符串“epdqdata” #此行包含加密字符串 $response\u line\u count=计数($response\u line);
对于($i=0;$i我认为其他一些帖子直接处理了您看到的问题,但是,我建议您考虑使用CURL()对于您尝试执行的操作,而不是手动打开套接字连接。您的支付提供商甚至可能有一些PHP代码示例。通常,这是处理与网关通信的更好方法,并且具有更大的灵活性

如果您与多个网关集成,这将特别方便,因为大多数都有CURL代码示例,将来您将发现它的其他用途

编辑:

甚至比PHP手册更好——本网站更清楚地说明了如何使用它,包括身份验证例程、传递post变量等,并举例说明:


我想你忘了
主机:
标题


但是,有更好的方法通过HTTP发布内容,而不是打开套接字并实现自己的HTTP客户端。请尝试
curl

我不清楚引用者如何适应您所做的工作。谁在抱怨它?远程站点,还是您?无法保证引用者的存在;您不能依赖它进行bas我什么都不知道。是的,我真的不知道。远程站点正在抱怨它。我在格式化被劫持时发布了这个答案——但这个建议仍然适用。=)
fputs( $fp, "Referer: ".$somereferer."\n" );