Search code examples
c#smssms-gateway

Already php sms function convert to C# success


i have already configured SMS gateway & some php code.Now my project is thatone convert it to Csharp with minor changes,

probably i have to write new code.but so.. experienced guys from you i wanted to know is that possible ? Sample code below.

enter code here
$username = "abcdsoft";
$password = "softsoft";

//GET parametrar 
//$source     = $_GET['sourceaddr'];
//$dest       = $_GET['destinationaddr'];
//$message_in = $_GET['message'];


enter code here
$source     = $_GET['msisdn'];
$dest       = $_GET['shortcode'];
$message_in = $_GET['msg'];

those are most top lines.below code i changed.(php to csharp)

enter code here
 string username ='abcdsoft';
 string password = 'abcdabcd';

 int source = ['sourceaddr'];
 int dest  = ['shortcode'];
 string message_in = ['msg'];

Is this way is correct ?


Solution

  • Almost.

    1. Need to use double-quotes for the string
    2. Request.QueryString is the ASP.NET equivalent to the PHP $_GET.
    3. Also, apparently C# is a bit more strongly typed than PHP, so you need to explicitly convert the query string params to integers.

    Code should be like this:

    string username = "abcdsoft";
    string password = "abcdabcd";
    
    int source = int.Parse(Request.QueryString["sourceaddr"]);
    int dest  = int.Parse(Request.QueryString["shortcode"]);
    string message_in = int.Parse(Request.QueryString["msg"]);