Log in

View Full Version : Issue with CURL



hemi519
09-05-2012, 01:46 PM
Hi All,

I am not exactly sure if i am doing it coreect or not but my issue is, in my site whenever user login into site a sms will go to the site-admin; For that i am using curl as mentioned below







//after login is successfull


$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://name/page.php?num=123456789&msg=test");

// link was provided by my sms api provider. When i manually click on that link, sms will work fine but i need it to be automatic whenever user login into the site.


curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec ($curl);





Above code is not working for me, just giving balnk page. Curl is installed in mine(Ubuntu) and tested.

djr33
09-05-2012, 03:58 PM
I have no idea about sending the SMS, but I can explain your blank page-- there's nothing displayed from the PHP. Add echo 'test'; to check-- you'll get that.

CURL is done completely on the server and (unless you display the results intentionally) nothing will show up for the user. It's "silent" or hidden in that sense. It looks like CURLOPT_RETURNTRANSFER should allow you to see the results, but it's possible that those results are completely blank.

To see if you're getting a "FALSE", you should check this code:
if(curl_exec($curl)===FALSE) { echo 'FALSE'; }
If you don't see anything, that probably means it's just returning a blank page and it "worked". But--

If you're not receiving the SMS, then you'll need to look at the SMS service and see what's wrong there.

hemi519
09-05-2012, 06:41 PM
thanks for the info, but, is there a way to execute a url without redirecting it to new page through php script

djr33
09-05-2012, 07:57 PM
Yes, curl is correct. That's what it's designed for. As I said, it looks roughly correct to me (although I don't use curl much-- it does seem to be a little less straight forward than other functions).