Results 1 to 2 of 2

Thread: how to covert following curl script to php curl script?

  1. #1
    Addicted Member
    Join Date
    Dec 09
    Posts
    197

    Question how to covert following curl script to php curl script?

    can any one help me to convert following curl code to php curl script?

    Code:
    curl -X POST 'https://api.twilio.com/2010-04-01/Accounts/xxx/SMS/Messages.xml' \
    -d 'From=%2Byyyy' \
    -d 'To=%2Bxxxx' \
    -d 'Body=Dear%2C+Plz+wake+up%3B+it'\''s+time+4+SAHERI.%0D%0AYour+1+night+sacrifice+will+make+thousands+night+wonderful+by+the+grace+of+almighty+ALLAH.%0D%0A%0D%0A-biplob+(%2Bxxxxx)' \
    -u xxx:yyy;
    best regards
    kamrul hassan

  2. #2
    Hyperactive Member xxarmoxx's Avatar
    Join Date
    Mar 07
    Posts
    365

    Re: how to covert following curl script to php curl script?

    This should work:

    Code:
    $to = "Joe";
    $from = "Momma";
    $body = "body here";
    $url = "https://api.twilio.com/2010-04-01/Accounts/xxx/SMS/Messages.xml?from={$from}&to={$to}&body={$body}";
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_TIMEOUT,5);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result  = curl_exec($ch);
    curl_close($ch);
    You can echo out $result.

    For further information check out the PHP manual: http://us2.php.net/manual/en/function.curl-exec.php
    Last edited by xxarmoxx; Jul 29th, 2012 at 12:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •