execute a url from php page without showing it

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raphsoft
    New Member
    • Jan 2009
    • 6

    execute a url from php page without showing it

    Execute a url from php page without showing it.

    This is what I have:
    [code=php]
    function send_sms($recei ver,$content)
    {
    $logIn = 'raphael';
    $pwd = 'pwd';
    $clientId = 'rg7U97fH7fUujp ';
    //$receiver = '238052433258';
    //$content = 'Just Testing';
    $Type = 'TEXT';
    $Sender = 'raphsoft';

    $url = "http://208.77.188.166: 8080/server/sendsms/?login=$logIn&p assword=$pwd&cl ientid=$clientI d&receiver=$rec eiver&message=$ content&message _type=$Type&sen der=$Sender";

    $_GET["$url");
    return
    }

    if
    (isset($_POST["send_messa ge"]) && $_POST["send_messa ge"] = "S E N D")
    {
    $receiver = $_POST["receiver"];
    $content = $_POST["contents"];
    $send_now = send_sms($recei ver,$content);

    if (isset($send_no w))
    {
    $_SESSION["msg"] = "You text message has been sent";
    }
    else
    {
    $_SESSION["msg"] = "Sorry, the message cannot be sent";
    }

    navigate("sms_s uccess.php");
    exit;


    }
    ?>
    [/code]
    Last edited by Atli; Jan 15 '09, 10:53 AM. Reason: Added [code] tags and replaced some of the more sensitive data.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Code:
    $_GET["$url"];
    won't work. $_GET contains the variables present in the url of your current file and the array key for $_GET should be a valid variable name.

    to just call the service I guess you should use some of the CURL functions. (PHP: cURL - Manual)

    regards

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hi.

      I suggest you try reading this:
      PHP: $_GET - Manual

      And then this:
      PHP: file_get_conten ts - Manual
      And if that fails, you could try this:
      PHP: cURL - Manual

      And finally, if you plan on staying a member on these forums, you should read this:
      FAQ: Posting Guidelines - Bytes

      Comment

      • raphsoft
        New Member
        • Jan 2009
        • 6

        #4
        This works but does not hide the url. Please help, it's urgent.
        [code=php]
        function send_sms($recei ver,$content)
        {
        $logIn = 'raphael';
        $pwd = 'pwd';
        $clientId = 'rg7U97fH7fUujp ';
        //$receiver = '238052433258';
        //$content = 'Just Testing';
        $Type = 'TEXT';
        $Sender = 'raphsoft';

        $url = "http://208.77.188.166: 8080/server/sendsms/?login=$logIn&p assword=$pwd&cl ientid=$clientI d&receiver=$rec eiver&message=$ content&message _type=$Type&sen der=$Sender";

        navigate("$url" );
        }

        if
        (isset($_POST["send_messa ge"]) && $_POST["send_messa ge"] = "S E N D")
        {
        $receiver = $_POST["receiver"];
        $content = $_POST["contents"];
        $send_now = send_sms($recei ver,$content);

        if (isset($send_no w))
        {
        $_SESSION["msg"] = "You text message has been sent";
        }
        else
        {
        $_SESSION["msg"] = "Sorry, the message cannot be sent";
        }

        navigate("sms_s uccess.php");
        exit;


        }
        ?>
        [/code]
        Last edited by Atli; Jan 15 '09, 11:31 AM. Reason: Added [code] tags. Please check your PMs!

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          Did you even try either of the methods we suggested?

          Both the file_get_conten ts function and the curl functions are capable of doing what you are asking for.

          Don't expect us to simply write the code for you. We wont.

          Comment

          • raphsoft
            New Member
            • Jan 2009
            • 6

            #6
            Sorry I did. But if u can't help no problem

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              I'm happy to help, but you are going to have to do the heavy lifting mate.

              If these two methods didn't work for you, show us what you tried and explain why/how it didn't work.
              Error messages and such are always a big help to.

              If we knew why those two methods won't working for you, maybe we could suggest alternate solutions.

              Comment

              • raphsoft
                New Member
                • Jan 2009
                • 6

                #8
                That is what I did it did not work
                [code=php]
                <?
                session_start() ;
                //include_once('t ext_class.php') ;
                function navigate($page) {echo "<script language='javas cript'>location ='$page';</script>";exit;}

                function send_sms($recei ver,$content)
                {
                $logIn = 'user';
                $pwd = 'pwd';
                $clientId = '7f7UHfUp';
                //$receiver = '230528332548';
                //$content = 'Just Testing';
                $Type = 'TEXT';
                $Sender = 'user';

                $url = "http://208.77.188.166: 8080/server/sendsms/?login=$logIn&p assword=$pwd&cl ientid=$clientI d&receiver=$rec eiver&message=$ content&message _type=$Type&sen der=$Sender";

                ///
                function curl_get_file_c ontents($url)
                {
                $c = curl_init();
                curl_setopt($c, CURLOPT_RETURNT RANSFER, 1);
                curl_setopt($c, CURLOPT_URL, $URL);
                $contents = curl_exec($c);
                curl_close($c);

                if ($contents) return $contents;
                else return FALSE;
                }

                curl_get_file_c ontents("$url") ;
                ///
                }

                if
                (isset($_POST["send_messa ge"]) && $_POST["send_messa ge"] = "S E N D")
                {
                $receiver = $_POST["receiver"];
                $content = $_POST["contents"];
                $send_now = send_sms($recei ver,$content);

                if (isset($send_no w))
                {
                $_SESSION["msg"] = "You text message has been sent";
                }
                else
                {
                $_SESSION["msg"] = "Sorry, the message cannot be sent";
                }

                navigate("sms_s uccess.php");
                exit;
                //include_once('h ttp://www.example.net ');
                //exit;



                }
                ?>
                [/code]
                Last edited by Atli; Jan 15 '09, 03:36 PM. Reason: Added [code] tags and removed sensitive info. Check your inbox at the top of the page!

                Comment

                • Dormilich
                  Recognized Expert Expert
                  • Aug 2008
                  • 8694

                  #9
                  although PHP doesn't complain when you define a function inside another function, it seems to be pointless (when I tried it, the inner function wasn't called)

                  Comment

                  • raphsoft
                    New Member
                    • Jan 2009
                    • 6

                    #10
                    I have removed the function the other function. But it is not working yet.

                    Code:
                    session_start();
                    //include_once('text_class.php');
                    function navigate($page) {echo "<script language='javascript'>location='$page';</script>";exit;}
                    
                    function curl_get_file_contents($url)
                        {
                            $c = curl_init();
                            curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
                            curl_setopt($c, CURLOPT_URL, $URL);
                            $contents = curl_exec($c);
                            curl_close($c);
                    
                            if ($contents) return $contents;
                                else return FALSE;
                        }
                    	
                    function send_sms($receiver,$content)
                    {
                    $logIn = 'user';
                    $pwd = 'pwd';
                    $clientId = '7UffUp';
                    //$receiver = '280433232558';
                    //$content = 'Just Testing';
                    $Type = 'TEXT';
                    $Sender = 'user';
                    
                    $url = "http://208.77.188.166:8080/server/sendsms/?login=$logIn&password=$pwd&clientid=$clientId&receiver=$receiver&message=$content&message_type=$Type&sender=$Sender";
                    						
                    ///
                    
                    curl_get_file_contents("$url");
                    ///
                    }
                    
                    if
                    (isset($_POST["send_message"]) && $_POST["send_message"] = "S E N D")
                    {
                    $receiver = $_POST["receiver"];
                    $content = $_POST["contents"];
                    $send_now = send_sms($receiver,$content);
                    
                    if (isset($send_now))
                    {
                    $_SESSION["msg"] = "You text message has been sent";
                    }
                    else
                    {
                    $_SESSION["msg"] = "Sorry, the message cannot be sent";
                    }
                    
                    navigate("sms_success.php");
                    exit;
                    //include_once('http://www.example.net');
                    //exit;
                    Last edited by Atli; Jan 15 '09, 03:44 PM. Reason: Removed sensitive info. (Markus added the code tags earlier).

                    Comment

                    • Atli
                      Recognized Expert Expert
                      • Nov 2006
                      • 5062

                      #11
                      PHP variables are case-sensitive.
                      Your $URL in line #9 does not match the parameter $url in line #5.
                      Try changing that.

                      Also, your send_sms() function does not return a value. Yet in line #42 you try to check the return value to see if it was successful. You need to add a return value to the function if that is supposed to work.

                      Add these lines at the top of your script. They will tell you if there are errors in it.
                      [code=php]
                      error_reporting (E_ALL);
                      ini_set('displa y_errors', true);[/code]

                      Comment

                      • raphsoft
                        New Member
                        • Jan 2009
                        • 6

                        #12
                        Atli, I tried what you said but did not get the right result. Anyway thank you!

                        Comment

                        Working...