如何将下面的PHP代码转换为VB.NET?

如何将下面的PHP代码转换为VB.NET?,php,vb.net,Php,Vb.net,如何将下面的PHP代码转换为VB.NET <?php $X_HOST ="foo.com"; $X_URL = "/index.php"; $X_PORT ="8080"; $X_USERNAME = "foo"; $X_PASSWORD = "bar"; $s_POST_DATA = "Channel=UK.VODAFONE"; // Channel $s_POST_DATA .= "&Shortcode=12345"; /

如何将下面的PHP代码转换为VB.NET

<?php
    $X_HOST ="foo.com";
    $X_URL = "/index.php";
    $X_PORT ="8080";
    $X_USERNAME = "foo";
    $X_PASSWORD = "bar";
    $s_POST_DATA = "Channel=UK.VODAFONE"; // Channel
    $s_POST_DATA .= "&Shortcode=12345"; // Shortcode
    $s_POST_DATA .= "&SourceReference=3456"; // Source Reference
    $s_POST_DATA .= "&MSISDN=447811111111"; // Phone
    $s_POST_DATA .= "&Content=test"; // Content
    $s_POST_DATA .= "&DataType=0"; // Data Type
    $s_POST_DATA .= "&Premium=1"; // Premium
    $s_POST_DATA .= "&CampaignID=4321"; // CampaignID
    $s_Request = "POST ".$X_URL." HTTP/1.0\r\n";
    $s_Request .="Host: ".$X_HOST.":".$X_PORT."\r\n";
    $s_Request .="Authorization: Basic ".base64_encode($X_USERNAME.":".$X_PASSWORD)."\r\n";
    $s_Request .="Content-Type: application/x-www-form-urlencoded\r\n";
    $s_Request .="Content-Length: ".strlen($s_POST_DATA)."\r\n";
    $s_Request .="\r\n".$s_POST_DATA;
    //Sends out the request to the server.
    $fp = fsockopen ($X_HOST, $X_PORT, $errno, $errstr, 30) or die("Error!!!");
    fputs ($fp, $s_Request);
    while (!feof($fp)) {
    $s_GatewayResponse .= fgets ($fp, 128);
    }
    fclose ($fp);
    //Array of official response codes.
    $a_Responses = array(
    "100" => "Server has returned an unspecified error.",
    "101" => "Server successfully received the request.",
    "102" => "Server has returned an database error",
    "103" => "Server has returned an syntax error."
    );
    echo "<HTML>\n<BODY>\n\n";
    //Checks for an official response code.
    foreach ($a_Responses as $s_ResponseCode => $s_ResponseDescription) {
    if (stristr($s_GatewayResponse, "\n$s_ResponseCode\n")) {
    echo "A response code of $s_ResponseCode was returned – ";
    echo $s_ResponseDescription";
    $b_CodeReturned = true;
    }
    }
    //Checks for an authorization failure where an official response code has 
    //not been recognized.
    if (!$b_CodeReturned) {
    if (stristr($s_GatewayResponse, "HTTP/1.1 401")) {
    echo "The server rejected your username/password (HTTP 401).";
    } else {
    echo "No recognised response code was returned by the server.";
    }
    }
    echo "\n\n</BODY>\n</HTML>";
    ?>

学习VB.NET,然后开始仔细地逐行翻译代码。这应该很简单

如果您不知道VB.NET中PHP函数的等价物,请查找或询问


或者:查看/询问与脚本目标相同的VB.NET预制解决方案。

第一组代码只是下载带有特定标题和身份验证的网页。看看这个班

另外两段代码只是从客户机检索POST的数据,然后将这些变量传递给getValidateReceipt()函数,该函数验证发送的内容,注意它是空的,所以它什么也不做

这看起来像是旧的PHP代码,因为使用CURL库和$\u POST将是更现代的做事方式。

对我很有用

基本上,这是一种将每种语言中的常见编程概念与连续的叙述并排进行比较的方法


我认为这是学习如何将PHP转换为vb.net的最佳方法

没有人会为您编写大量代码。你到底不懂什么?如果你懂任何语言,代码都很容易理解……对不起,对不起,对不起,我明白了。(我的意思是-3分)+1只是b/c我为你感到难过。这是一个非常有帮助的社区,在你寻求帮助之前,你只需要证明你自己做了一些腿部工作。
<?php
    $s_ref = $HTTP_POST_VARS["Reference"]; // Reference
    $s_trg = $HTTP_POST_VARS["Trigger"]; // trigger
    $s_shc = $HTTP_POST_VARS["Shortcode"]; // shortcode
    $s_pho = $HTTP_POST_VARS["MSISDN"]; // MSISDN
    $s_con = $HTTP_POST_VARS["Content"]; // Content
    $s_chn = $HTTP_POST_VARS["Channel"]; // Channel
    $s_pay = $HTTP_POST_VARS["DataType"]; // Data Type
    $s_dat = $HTTP_POST_VARS["DateReceived"]; // Date Received
    $s_cam = $HTTP_POST_VARS["CampaignID"]; // CampaignID
    $b_IsValid = getValidateRequest($s_ref, $s_trg, $s_shc, $s_pho, $s_con, $s_cam, $s_chn, $s_pay, 
    $s_dat);
    if ($b_IsValid) 
    {
    $s_ResponseCode = "success";
    } 
    else 
    {
    $s_ResponseCode = "fail";
    }
    exit($s_ResponseCode);
    /*******************************************************************************/
    function getValidateRequest ($s_req_ref, $s_req_trg, $s_req_shc, $s_req_pho, $s_req_con, $s_req_cam, 
    $s_req_chn, $s_req_pay, $s_req_dat) {
    /*
     * Stub function to be replaced with whatever process is needed to
     * process/validate request from server by specific client requirements.
     */
    return(true);
    }
    ?>
    <?php
$s_ref = $HTTP_POST_VARS["Reference"]; // Reference
$s_sta = $HTTP_POST_VARS["Status"]; // Status
$s_dat = $HTTP_POST_VARS["DateDelivered"]; // Date Delivered
$b_IsValid = getValidateReceipt($s_ref, $s_sta, $s_dat);
if ($b_IsValid) 
{
$s_ResponseCode = "success";
} 
else 
{
$s_ResponseCode = "fail";
}
exit($s_ResponseCode);
/*******************************************************************************/
function getValidateReceipt ($s_req_ref, $s_req_sta, $s_req_dat) 
{
/*
 * Stub function to be replaced with whatever process is needed to
 * process/validate receipts from server by specific client requirements.
 */
return(true);
}
?>