469,326 Members | 1,576 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

execute a url from php page without showing it

Execute a url from php page without showing it.

This is what I have:
Expand|Select|Wrap|Line Numbers
  1. function send_sms($receiver,$content)
  2. {
  3. $logIn = 'raphael';
  4. $pwd = 'pwd';
  5. $clientId = 'rg7U97fH7fUujp';
  6. //$receiver = '238052433258';
  7. //$content = 'Just Testing';
  8. $Type = 'TEXT';
  9. $Sender = 'raphsoft';
  10.  
  11. $url = "http://208.77.188.166:8080/server/sendsms/?login=$logIn&password=$pwd&clientid=$clientId&receiver=$receiver&message=$content&message_type=$Type&sender=$Sender";
  12.  
  13. $_GET["$url");
  14. return
  15. }
  16.  
  17. if
  18. (isset($_POST["send_message"]) && $_POST["send_message"] = "S E N D")
  19. {
  20. $receiver = $_POST["receiver"];
  21. $content = $_POST["contents"];
  22. $send_now = send_sms($receiver,$content);
  23.  
  24. if (isset($send_now))
  25. {
  26. $_SESSION["msg"] = "You text message has been sent";
  27. }
  28. else
  29. {
  30. $_SESSION["msg"] = "Sorry, the message cannot be sent";
  31. }
  32.  
  33. navigate("sms_success.php");
  34. exit;
  35.  
  36.  
  37. }
  38. ?>
  39.  
Jan 15 '09 #1
11 64320
Dormilich
8,651 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. $_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
Jan 15 '09 #2
Atli
5,058 Expert 4TB
Hi.

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

And then this:
PHP: file_get_contents - 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
Jan 15 '09 #3
This works but does not hide the url. Please help, it's urgent.
Expand|Select|Wrap|Line Numbers
  1. function send_sms($receiver,$content) 
  2. $logIn = 'raphael'; 
  3. $pwd = 'pwd'; 
  4. $clientId = 'rg7U97fH7fUujp'; 
  5. //$receiver = '238052433258'; 
  6. //$content = 'Just Testing'; 
  7. $Type = 'TEXT'; 
  8. $Sender = 'raphsoft'; 
  9.  
  10. $url = "http://208.77.188.166:8080/server/sendsms/?login=$logIn&password=$pwd&clientid=$clientId&receiver=$receiver&message=$content&message_type=$Type&sender=$Sender"; 
  11.  
  12. navigate("$url"); 
  13.  
  14. if 
  15. (isset($_POST["send_message"]) && $_POST["send_message"] = "S E N D") 
  16. $receiver = $_POST["receiver"]; 
  17. $content = $_POST["contents"]; 
  18. $send_now = send_sms($receiver,$content); 
  19.  
  20. if (isset($send_now)) 
  21. $_SESSION["msg"] = "You text message has been sent"; 
  22. else 
  23. $_SESSION["msg"] = "Sorry, the message cannot be sent"; 
  24.  
  25. navigate("sms_success.php"); 
  26. exit; 
  27.  
  28.  
  29. ?>
  30.  
Jan 15 '09 #4
Atli
5,058 Expert 4TB
Did you even try either of the methods we suggested?

Both the file_get_contents 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.
Jan 15 '09 #5
Sorry I did. But if u can't help no problem
Jan 15 '09 #6
Atli
5,058 Expert 4TB
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.
Jan 15 '09 #7
That is what I did it did not work
Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. //include_once('text_class.php');
  4. function navigate($page) {echo "<script language='javascript'>location='$page';</script>";exit;}
  5.  
  6. function send_sms($receiver,$content)
  7. {
  8. $logIn = 'user';
  9. $pwd = 'pwd';
  10. $clientId = '7f7UHfUp';
  11. //$receiver = '230528332548';
  12. //$content = 'Just Testing';
  13. $Type = 'TEXT';
  14. $Sender = 'user';
  15.  
  16. $url = "http://208.77.188.166:8080/server/sendsms/?login=$logIn&password=$pwd&clientid=$clientId&receiver=$receiver&message=$content&message_type=$Type&sender=$Sender";
  17.  
  18. ///
  19. function curl_get_file_contents($url)
  20.     {
  21.         $c = curl_init();
  22.         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  23.         curl_setopt($c, CURLOPT_URL, $URL);
  24.         $contents = curl_exec($c);
  25.         curl_close($c);
  26.  
  27.         if ($contents) return $contents;
  28.             else return FALSE;
  29.     }
  30.  
  31. curl_get_file_contents("$url");
  32. ///
  33. }
  34.  
  35. if
  36. (isset($_POST["send_message"]) && $_POST["send_message"] = "S E N D")
  37. {
  38. $receiver = $_POST["receiver"];
  39. $content = $_POST["contents"];
  40. $send_now = send_sms($receiver,$content);
  41.  
  42. if (isset($send_now))
  43. {
  44. $_SESSION["msg"] = "You text message has been sent";
  45. }
  46. else
  47. {
  48. $_SESSION["msg"] = "Sorry, the message cannot be sent";
  49. }
  50.  
  51. navigate("sms_success.php");
  52. exit;
  53. //include_once('http://www.example.net');
  54. //exit;
  55.  
  56.  
  57.  
  58. }
  59. ?>
  60.  
Jan 15 '09 #8
Dormilich
8,651 Expert Mod 8TB
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)
Jan 15 '09 #9
I have removed the function the other function. But it is not working yet.

Expand|Select|Wrap|Line Numbers
  1. session_start();
  2. //include_once('text_class.php');
  3. function navigate($page) {echo "<script language='javascript'>location='$page';</script>";exit;}
  4.  
  5. function curl_get_file_contents($url)
  6.     {
  7.         $c = curl_init();
  8.         curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  9.         curl_setopt($c, CURLOPT_URL, $URL);
  10.         $contents = curl_exec($c);
  11.         curl_close($c);
  12.  
  13.         if ($contents) return $contents;
  14.             else return FALSE;
  15.     }
  16.  
  17. function send_sms($receiver,$content)
  18. {
  19. $logIn = 'user';
  20. $pwd = 'pwd';
  21. $clientId = '7UffUp';
  22. //$receiver = '280433232558';
  23. //$content = 'Just Testing';
  24. $Type = 'TEXT';
  25. $Sender = 'user';
  26.  
  27. $url = "http://208.77.188.166:8080/server/sendsms/?login=$logIn&password=$pwd&clientid=$clientId&receiver=$receiver&message=$content&message_type=$Type&sender=$Sender";
  28.  
  29. ///
  30.  
  31. curl_get_file_contents("$url");
  32. ///
  33. }
  34.  
  35. if
  36. (isset($_POST["send_message"]) && $_POST["send_message"] = "S E N D")
  37. {
  38. $receiver = $_POST["receiver"];
  39. $content = $_POST["contents"];
  40. $send_now = send_sms($receiver,$content);
  41.  
  42. if (isset($send_now))
  43. {
  44. $_SESSION["msg"] = "You text message has been sent";
  45. }
  46. else
  47. {
  48. $_SESSION["msg"] = "Sorry, the message cannot be sent";
  49. }
  50.  
  51. navigate("sms_success.php");
  52. exit;
  53. //include_once('http://www.example.net');
  54. //exit;
Jan 15 '09 #10
Atli
5,058 Expert 4TB
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.
Expand|Select|Wrap|Line Numbers
  1. error_reporting(E_ALL);
  2. ini_set('display_errors', true);
Jan 15 '09 #11
Atli, I tried what you said but did not get the right result. Anyway thank you!
Jan 16 '09 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Metnetsky | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.