Niki131 Posted May 31, 2011 Share Posted May 31, 2011 Hello, I'm new to lot of this and especially php. I'm having hard time with one of my app that I created. If you go to ticketlawyerorlando.com/sms5.html and you try to send text, (which is set to go to only one number (mine)) than I get error code from php that is supposed to curl it. Error: Warning: curl_setopt() [function.curl-setopt]: Invalid curl configuration option in /home/content/s/j/1/sj10mil/html/ticketlawyerorlando/sms5.php on line 10 SUCCESS My Html code is : <html> <body> <br/> <form action="sms5.php" method="post"> <b>Your Phone Number:</b> <input type="text" name="to" /> <br/> <b>Message:</b> <input type="text" name="msg" /> <br/> <input type="submit" /> </form> </body> </html> My sms5.php code is : <html> <head> <title>SMS STATUS</title> </head> <body> <?php //print $to; //print $msg; $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_GET,1); curl_setopt($curl_handle, CURLOPT_URL,'https://api.tropo.com/1.0/sessions?to=3213314633&msg=test4&token=010fc32265db5444bbf84e92bd28f1887395ce3ade6cf69e1424d586add66b17bdc7c1d8061803f1c2319d66'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,2); $response = curl_exec($curl_handle); $code = curl_getinfo($curl_handle,CURLINFO_HTTP_CODE); //print $code; //print $response; print "SUCCESS"; curl_close($curl_handle); ?> </body> </html> In my php, the URL that's being curled, in the part where it says "test4" that should be actual message that is typed in the form but I don't know what kind of parameter to insert there in order for it to send message that's written, it always sends message "test4". Please, if you could help me I would greatly appreciate it. Thank You so much again. MOD EDIT: code tags added Quote Link to comment Share on other sites More sharing options...
xyph Posted May 31, 2011 Share Posted May 31, 2011 &msg=test4 might have something to do with it. CURLOPT_GET isn't a possible curl option. http://php.net/manual/en/function.curl-setopt.php Quote Link to comment Share on other sites More sharing options...
Niki131 Posted May 31, 2011 Author Share Posted May 31, 2011 Ok yes that's probably the problem, but can I input something there instead of the "Test4" part so it would show message? That's the sms app code: <?php message("".$msg, array( "to" => "+13213314633", "network" => "SMS")); ?> So if I use CURLOPT_POST ? I tried that before nothing helped MOD EDIT: code tags added. Quote Link to comment Share on other sites More sharing options...
Niki131 Posted May 31, 2011 Author Share Posted May 31, 2011 If I changed the sms5.php to: <html> <head> <title>SMS STATUS</title> </head> <body> <?php //print $to; //print $msg; $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_POST); curl_setopt($curl_handle, CURLOPT_URL,'https://api.tropo.com/1.0/sessions?to=3213314633&msg=test4&token=010fc32265db5444bbf84e92bd28f1887395ce3ade6cf69e1424d586add66b17bdc7c1d8061803f1c2319d66'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,2); $response = curl_exec($curl_handle); $code = curl_getinfo($curl_handle,CURLINFO_HTTP_CODE); //print $code; //print $response; print "SUCCESS"; curl_close($curl_handle); ?> </body> </html> I get this error: Warning: Wrong parameter count for curl_setopt() in /home/content/s/j/1/sj10mil/html/ticketlawyerorlando/sms5.php on line 10 SUCCESS Thank you for all your help again. MOD EDIT: code tags added Quote Link to comment Share on other sites More sharing options...
xyph Posted May 31, 2011 Share Posted May 31, 2011 Line 10 is redundant. CURLOPT_HTTPGET - TRUE to reset the HTTP request method to GET. Since GET is the default, this is only necessary if the request method has been changed. As long as you have &msg=test4 in your CURLOPT_URL, all you will get is test4. You want to sanitize (htmlentities) and make sure it's not to long, and then insert the message into your CURLOPT_URL query string Quote Link to comment Share on other sites More sharing options...
Niki131 Posted May 31, 2011 Author Share Posted May 31, 2011 Ok so should I insert CURLOPT_HTTPGET - TRUE somewhere in the php code? Ok, i see that, so but if i delete that part, than it's not sending any kind of message.....I don't even know how to sanitize it correctly, I was told to use : curl_setopt($curl_handle, CURLOPT_URL,'https://api.tropo.com/1.0/sessions?action=create&token=YOUR_TOKEN_GOES_HERE&to='.$to.'&msg='.$msg); but that code wasn't working, insteas o Your Token GOes Here i put my token nubmer which is 010fc32265db5444bbf84e92bd28f1887395ce3ade6cf69e1424d586add66b17bdc7c1d8061803f1c2319d66 so resulting url should look something like this 'https://api.tropo.com/1.0/sessions?action=create&token=010fc32265db5444bbf84e92bd28f1887395ce3ade6cf69e1424d586add66b17bdc7c1d8061803f1c2319d66&to='.$to.'&msg='.$msg right? Quote Link to comment Share on other sites More sharing options...
xyph Posted May 31, 2011 Share Posted May 31, 2011 http://www.tizag.com/phpT/ Quote Link to comment Share on other sites More sharing options...
Niki131 Posted May 31, 2011 Author Share Posted May 31, 2011 Thank you for the reply again, I've been on that site too, it's just so new to me, I'm having hard time recreating that php code to make it work, is there any way you could show me an example of what it should look like for it to work? Please Thank You so much again Quote Link to comment Share on other sites More sharing options...
xyph Posted May 31, 2011 Share Posted May 31, 2011 Then I'd be doing it for you, and you wouldn't learn anything. The skills required to complete your task, given the information provided in this thread, are VERY BASIC. I'm here to help, not fix your scripts. Quote Link to comment Share on other sites More sharing options...
Niki131 Posted May 31, 2011 Author Share Posted May 31, 2011 Please, please, please help me, I promise you I will definitely learn a lot form it, I can compare the codes than and see what I was doing wrong, I promise. Please I'll owe you a big one, I really need help with this Please. THANK YOU so much again Quote Link to comment Share on other sites More sharing options...
xyph Posted May 31, 2011 Share Posted May 31, 2011 <?php $var = 'beautiful'; echo 'Hello '.$var.' World'; ?> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted May 31, 2011 Share Posted May 31, 2011 When posting code, enclose it within the forum's . . . BBCode tags. Quote Link to comment Share on other sites More sharing options...
Niki131 Posted May 31, 2011 Author Share Posted May 31, 2011 Xyph: where should I put this code? <?php $var = 'beautiful'; echo 'Hello '.$var.' World'; ?> And thank You so much. Quote Link to comment Share on other sites More sharing options...
Niki131 Posted May 31, 2011 Author Share Posted May 31, 2011 Pikachu2000 Hey thank you for the response, where should I put those tags? by which code? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted May 31, 2011 Share Posted May 31, 2011 Like this: <?php if( $some_var == $some_value) { echo "Some random string"; } ?> So the enclosed code is automatically syntax highlighted like this: <?php if( $some_var == $some_value) { echo "Some random string"; } ?> Quote Link to comment Share on other sites More sharing options...
Niki131 Posted May 31, 2011 Author Share Posted May 31, 2011 o ok, so here are my codes than: sms5.php code: <html> <head> <title>SMS STATUS</title> </head> <body> <?php //print $to; //print $msg; $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_GET,1); curl_setopt($curl_handle, CURLOPT_URL,'https://api.tropo.com/1.0/sessions?to=3213314633&msg=test4&token=010fc32265db5444bbf84e92bd28f1887395ce3ade6cf69e1424d586add66b17bdc7c1d8061803f1c2319d66'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,5); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,2); $response = curl_exec($curl_handle); $code = curl_getinfo($curl_handle,CURLINFO_HTTP_CODE); //print $code; //print $response; print "SUCCESS"; curl_close($curl_handle); ?> </body> </html> sms app code: <?php message("".$msg, array( "to" => " +13213314633 ", "network" => "SMS")); ?> Can you by any chance help me with my problem? Quote Link to comment Share on other sites More sharing options...
Niki131 Posted May 31, 2011 Author Share Posted May 31, 2011 xyph: can you please pleas help me, I'm really new to this, could you write me the correct code? Please, or point where I'm making the mistake, it's saying line 10 but I can't see where is the mistake in there. Anybody? Please Thank You Quote Link to comment 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.