uiol

Embed Size (px)

Citation preview

  • 7/28/2019 uiol

    1/5

    Stack Exchangesign up log in careers 2.0

    Stack Overflow

    QuestionsTagsTourUsers

    Ask Question

    Tell me more Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.Curl outputs variable name instead of its contentsup vote -2 down vote favorite

    Below is my code, after searching and working all night, I finally figured how to make it send an sms. The problem is that I can't leave spaces in the body message and it does not display the value of $smsmessage.

    extract($_POST);

    $smsmessage1 = "This is the sms that will be sent";$smsmessage = urlencode($smsmessage1);

    //set POST variables$url = 'http://www.mysmsgateway.com/bulksms/[email protected]&password=123456789&message=$smsmessage&mobile=2348035081907&sender=Boss';$fields = array();

    //url-ify the data for the POSTforeach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }rtrim($fields_string,'&');

    //open connection$ch = curl_init();

    //set the url, number of POST vars, POST datacurl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_POST,count($fields));curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

    //execute post$result = curl_exec($ch);

    //close connection

    curl_close($ch);

    The above codes sends the message but will output $smsmessage instead of fetching the value of $smsmessage from above.php curlshare|improve this question

    edited May 16 '11 at 7:57Marcel Korpel12.1k22349

  • 7/28/2019 uiol

    2/5

    asked May 16 '11 at 7:17Naira4Dollar74

    Please use code block to put your code... you will not get reply with such a confusing code... Ummar May 16 '11 at 7:232

    edit, don't complain John Sheehan May 16 '11 at 23:153 Answersactive oldest votesup vote 6 down vote accepted

    You're using single quotes for specifying $url, which means the $smsmessage won't be interpreted.

    You'll need to use double quotes instead:

    $url = "http://www.mysmsgateway.com/bulksms/[email protected]&password=123456789&message=$smsmessage&mobile=2348035081907&sender=Boss";

    For more information about the difference between the two, see PHP: Strings fromthe PHP manual.share|improve this answer

    edited May 16 '11 at 7:50

    answered May 16 '11 at 7:25Sebastian Paaske Trholm18k22763

    You guys are God sent, this is gonna be my community. Thanks all... finally, eve

    rything is working fine. u've made my day. Naira4Dollar May 16 '11 at 8:04

    @Naira4Dollar: Happy to help. Remember to accept an answer if your problem is solved. :) Sebastian Paaske Trholm May 16 '11 at 8:39

    How do I accept answer? Naira4Dollar May 16 '11 at 12:02

    @Naira4Dollar: You click the checkmark on the left of the answer you like the best. :) Sebastian Paaske Trholm May 16 '11 at 16:17up vote 0 down vote

    Variables placed inside single quote are not evaluated in php, place them in dou

    ble quote. like

    //set POST variables$url = "http://www.mysmsgateway.com/bulksms/[email protected]&password=123456789&message=$smsmessage&mobile=2348035081907&sender=Boss"

    share|improve this answer

    answered May 16 '11 at 7:26Ummar

  • 7/28/2019 uiol

    3/5

  • 7/28/2019 uiol

    4/5

    2 years agoRelated0log into a site using curl3PHP CURL to CodeIgniter controller0Need help logging to remote site with PHP using cURL2PHP Curl POST/SESSION/COOKIE Issue0cURL in PHP While Loop only runs once0php cURL post to external domain and work with response-2Curl POST to external domain-1MySQL display multiple data and pass though CURL-1Not getting the content of webpage using Curl in Php0php CURL not show any responsequestion feedabout help badges blog chat data legal privacy policy jobs advertising info mobi

    le contact us feedbackTechnology Life / Arts Culture / Recreation Science Other

    Stack OverflowServer FaultSuper UserWeb ApplicationsAsk UbuntuWebmastersGame DevelopmentTeX - LaTeX

    ProgrammersUnix & LinuxAsk Different (Apple)WordPress AnswersGeographic Information SystemsElectrical EngineeringAndroid EnthusiastsIT Security

    Database Administrators

    Drupal AnswersSharePointUser ExperienceMathematicamore (13)

    PhotographyScience Fiction & Fantasy

  • 7/28/2019 uiol

    5/5

    Seasoned Advice (cooking)Home Improvementmore (13)

    English Language & UsageSkepticsMi Yodeya (Judaism)TravelChristianityArqade (gaming)BicyclesRole-playing Gamesmore (21)

    MathematicsCross Validated (stats)Theoretical Computer SciencePhysicsmore (7)

    Stack AppsMeta Stack OverflowArea 51Stack Overflow Careers

    site design / logo 2013 stack exchange inc; user contributions licensed under cc-wiki with attribution requiredrev 2013.6.22.757