当使用POST错误结果时,PHP GET(CURL)不返回结果

时间:2016-04-10 01:19:34

标签: php html

Hello Stackers,

这次我遇到了来自Targetpay.com的Api错误。但是,我想,失败在我的代码中。使用以下代码,我根本没有得到结果。我也用POST尝试过,但这总是返回相同的错误,代码不存在。

这段代码有什么作用?它是用于发送消息的Payment API。他们说你需要用GET检查PIN码(早先称之为代码)。

PHP

function checkPIN($code){

  $rtlo = "65235";       
  $keyword="BETAAL+AG";  
  $shortcode="3010";     
  $co= "31";            
  $test="0";

  $sRequest="http://www.targetpay.com/api/sms-pincode";
  $strParamString = "?rtlo=".$rtlo."&keyword=".$keyword.
    "&code=".$code."&shortcode=".$shortcode."&country=".$co.
    "&test=".$test;



  $ch = curl_init($sRequest.$strParamString);
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ;
  $strResponse = curl_exec($ch);
  curl_close($ch);

  return $strResponse;


}


if(isset($_GET['pincode'])){
  $strResponse = checkPIN($_GET['pincode']);

 if ($strResponse == "103 No pincode specified"){
     $makelog = mysql_query("INSERT INTO cms_shoplog(username, product, method, date, response) VALUES ('".$user['id']."', '5 Belcredits', 'SMS Betaling','".$time."','1')")or die(mysql_error());
    echo "<div class='alert alert-dismissible alert-danger' style='margin-left:20px; margin-right:20px; margin-top:17px;'>";    
    echo "<strong>Hey {username}!</strong> Je SMSCODE mag niet leeg zijn.";
    echo "</div>";
    } else
    if ($strResponse == "000 OK"){
        $makelog = mysql_query("INSERT INTO cms_shoplog (username, product, method, date, response) VALUES ('".$user['id']."', '5 Belcredits', 'SMS Betaling','".$time."','3')")or die(mysql_error());
        $givebelcredits = mysql_query("UPDATE users SET vip_points = vip_points + 5 WHERE id = '".$user['id']."'"); 
    echo "<div class='alert alert-dismissible alert-success' style='margin-left:20px; margin-right:20px; margin-top:17px;'>";   
    echo "<strong>Hey {username}!</strong> Je hebt 5 Belcredits gekocht.";
    echo "</div>";
    } else
    if ($strResponse == "106 Pincode already checked or not paid"){
        $makelog = mysql_query("INSERT INTO cms_shoplog (username, product, method, date, response) VALUES ('".$user['id']."', '5 Belcredits', 'SMS Betaling','".$time."','4')")or die(mysql_error());
    echo "<div class='alert alert-dismissible alert-danger' style='margin-left:20px; margin-right:20px; margin-top:17px;'>";    
    echo "<strong>Hey {username}!</strong> Deze code is niet (meer) geldig.";
    echo "</div>";
    } else
    if ($strResponse == "104 Pincode length incorrect"){
            $makelog = mysql_query("INSERT INTO cms_shoplog (username, product, method, date, response) VALUES ('".$user['id']."', '5 Belcredits', 'SMS Betaling','".$time."','1')")or die(mysql_error());
    echo "<div class='alert alert-dismissible alert-danger' style='margin-left:20px; margin-right:20px; margin-top:17px;'>";    
    echo "<strong>Hey {username}!</strong> Je SMSCODE mag niet leeg zijn.";
    echo "</div>";
    } else
    {
            $makelog = mysql_query("INSERT INTO cms_shoplog (username, product, method, date, response) VALUES ('".$user['id']."', '5 Belcredits', 'SMS Betaling','".$time."','1')")or die(mysql_error());
    echo "<div class='alert alert-dismissible alert-danger' style='margin-left:20px; margin-right:20px; margin-top:17px;'>";    
    echo $strResponse;
    echo "</div>";
    } 

HTML表单

<form method="get">
<input type="text" maxlength="6" style="margin-left:5px; margin-top:0px; color:#000000;"  name="pincode" placeholder="Vul SMSCODE in">
<input style="margin-left:10px; margin-top:-3px;" class="btn btn-default" type="submit" name="finishpayment" value="Betaling afronden">
</form>

我只想要结果,也是$strResponse的值。当我们谈论PHP或HTML时,我是否做错了什么?我很抱歉使用了Deprecated MySQL。

0 个答案:

没有答案