candeman Posted January 15, 2008 Share Posted January 15, 2008 Hello everyone I'm new here and desperately looking for an answer. I use cURL to Post to to a remote server (mediatemple) from m localhost server. This works fine as long as I open the page in a browser, however I'm using an sms server that executes php script in the background. when an sms is received the local php script runs and I want to use use cURL to execute script on a remote host. Again it works if I test the local php script in a browser, but it doesnt work when executed with the sms server. Is there some cURL pararmeter I can use, that may prevent the script from not being executed if its not loaded from a browser, or is there any way I can see the result of the php page that is loaded in the background, by mean of a log or something? Thanks for your time Hank from the Bahamas Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/ Share on other sites More sharing options...
kenrbnsn Posted January 15, 2008 Share Posted January 15, 2008 Please post some of the relevant code between tags. Ken Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440050 Share on other sites More sharing options...
Fyorl Posted January 15, 2008 Share Posted January 15, 2008 How is the SMS server executing the php script? Is it using the CLI version of PHP? Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440051 Share on other sites More sharing options...
candeman Posted January 15, 2008 Author Share Posted January 15, 2008 $phoneNumber = '4045551111'; $message = 'This message was generated by curl and php'; $curlPost = 'pNUMBER=' . urlencode($phoneNumber) . '&MESSAGE=' . urlencode($message) . '&SUBMIT=Send'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.example.com/sendSMS.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); $data = curl_exec(); curl_close($ch); This is not my exact code, but I'm at work and cant access it but this is essentially it, again its works and if I try it in a browser it works but executed from within server no Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440059 Share on other sites More sharing options...
candeman Posted January 15, 2008 Author Share Posted January 15, 2008 How is the SMS server executing the php script? Is it using the CLI version of PHP? Not sure don't even know with CLI version is, but I think sms server uses the php installed on my server, I'm using the latest version of XAMPP Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440061 Share on other sites More sharing options...
candeman Posted January 15, 2008 Author Share Posted January 15, 2008 Also because I got this to work using a browser..... I used header("www.mysite.php?".var=url_encode('example')) and was able to redirect the local page to the remote page with the POST vars I wanted, is it possible to do this or something equivalent without using a browser? Basically I need to post vars to a remote server without a browser Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440071 Share on other sites More sharing options...
GingerRobot Posted January 15, 2008 Share Posted January 15, 2008 If i understand your question correctly, you can use cURL. See here Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440091 Share on other sites More sharing options...
Fyorl Posted January 15, 2008 Share Posted January 15, 2008 Erm... if I understand his question properly, he's already using cURL. The clue's in the topic title and the code he's posted. I'm just wondering how the server is running the script? Is it a cron job? How is it physically running the code? Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440310 Share on other sites More sharing options...
KrisNz Posted January 15, 2008 Share Posted January 15, 2008 Well, cURL can impersonate a browser if thats helpful.... curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); But what exactly doesn't work? Try adding something like this to the top of your script so that you can see any errors when its run on your sms server. error_reporting(E_ERROR); ini_set('error_log', '/some/writable/path/errorlog'); Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440328 Share on other sites More sharing options...
GingerRobot Posted January 15, 2008 Share Posted January 15, 2008 Erm... if I understand his question properly, he's already using cURL. The clue's in the topic title and the code he's posted. Yes, i know - i've not gone completely insane, i've just absolutely no idea what happened here. When i posted, my reply was the first - and the question being asked was rather different. I came back later and checked the topic only to find that lots of people had posted before me and the question had changed. All very bizarre. Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440333 Share on other sites More sharing options...
Fyorl Posted January 15, 2008 Share Posted January 15, 2008 Actually, come to think of it your reply did seem familiar to a reply in another topic I read very recently. It made more sense in that topic than this one. I can't remember what it was called though. I'll have a root around and perhaps this mystery can be solved. Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440337 Share on other sites More sharing options...
GingerRobot Posted January 15, 2008 Share Posted January 15, 2008 Actually, come to think of it your reply did seem familiar to a reply in another topic I read very recently. It made more sense in that topic than this one. I can't remember what it was called though. I'll have a root around and perhaps this mystery can be solved. That topic IS this topic. If i view my last posts, the title of the topic is different, but it links to this one. I guess SMF just had a funny 5 minutes. Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440347 Share on other sites More sharing options...
Fyorl Posted January 15, 2008 Share Posted January 15, 2008 Yeah... that is really weird. Ugh, it's messing with my head. I'm trying to remember what was said before. I think I'll just leave it and put it down to, as you said, SMF having a funny five minutes. Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440352 Share on other sites More sharing options...
candeman Posted January 16, 2008 Author Share Posted January 16, 2008 Thank you for your time, I found the answer to my problem. The server software I use has a php plugin that triggers when sms are received it also has a 'HTTP Client' plugin, Apparently the request I was trying to make doest work with that php plugin, not sure why as it does all other php related functions connection to database etc. Using the http Client directed to the same php file EVERYTHING works. Sure you smart people understand why that is, but I'm satisfied with it just working!, Thanks and sorry for your time! Quote Link to comment https://forums.phpfreaks.com/topic/86163-solved-curl-remote-server-no-browser-please-help/#findComment-440516 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.