Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7038617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:41:27+00:00 2026-05-28T01:41:27+00:00

I am failing to post using curl in php to the url: http://example.com/sms/sms.aspx The

  • 0

I am failing to post using curl in php to the url: http://example.com/sms/sms.aspx

The post string should be in the pattern:example.com/sms/sms.aspx?uid=9746674889&pwd=passwod&phone=9746674889&msg=hjgyjgKJKJK&provider=way2sms&send=SEND

If it is posted the output will Be 1 else -1

Can anyone help me in the curl part

<?php


//extract data from the post
  // extract($_GET);

           $uid = $_GET['uid'];
           $phone = $_GET['phone'];
           $pwd = $_GET['pwd'];
           $msg = $_GET['msg'];
           $provider = 'way2sms';


//set POST variables



$fields = array(
                            'uid'=>rawurlencode($uid),
                            'phone'=>rawurlencode($phone),
                            'pwd'=>rawurlencode($pwd),
                            'msg'=>rawurlencode($msg),
                            'provider'=>rawurlencode($provider)
                );

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

///curl part(please help)

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:41:27+00:00Added an answer on May 28, 2026 at 1:41 am

    Here is a basic cURL POST script. It has no error handling – you should definitely read the cURL manual.

    <?php
    
      // Destination URL
      $url = 'http://ubaid.tk/sms/sms.aspx';
    
      // Raw data to send
      $fields = array(
       'uid' => $_GET['uid'],
       'phone'=>$_GET['phone'],
       'pwd'=>$_GET['pwd'],
       'msg'=>$_GET['msg'],
       'provider'=>'way2sms'
      );
    
      // Build $fields into an encoded string
      $body = http_build_query($fields);
    
      // Initialise cURL
      $ch = curl_init($url);
    
      // Set options (post request, return body from exec)
      curl_setopt($ch, CURLOPT_POST, TRUE);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    
      // Do the request
      $result = curl_exec($ch);
    
      // Echo the result
      echo $result;
    

    EDIT

    Since what you actually want is GET and not POST, the code gets a lot simpler:

    <?php
    
      // Destination URL
      $url = 'http://ubaid.tk/sms/sms.aspx';
    
      // Raw data to send
      $fields = array(
       'uid' => $_GET['uid'],
       'phone'=>$_GET['phone'],
       'pwd'=>$_GET['pwd'],
       'msg'=>$_GET['msg'],
       'provider'=>'way2sms'
      );
    
      // Build $fields into an encoded string and append to URL
      $url .= '?'.http_build_query($fields);
    
      // Initialise cURL
      $ch = curl_init($url);
    
      // Set options (post request, return body from exec)
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    
      // Do the request
      $result = curl_exec($ch);
    
      // Echo the result
      echo $result;
    

    …or this whole thing could be done without cURL as:

    <?php
    
      // Destination URL
      $url = 'http://ubaid.tk/sms/sms.aspx';
    
      // Raw data to send
      $fields = array(
       'uid' => $_GET['uid'],
       'phone'=>$_GET['phone'],
       'pwd'=>$_GET['pwd'],
       'msg'=>$_GET['msg'],
       'provider'=>'way2sms'
      );
    
      // Build $fields into an encoded string and append to URL
      $url .= '?'.http_build_query($fields);
    
      // Do the request
      $result = file_get_contents($url);
    
      // Echo the result
      echo $result;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making an HTTP POST request using curl like this: curl -v -i -d
I'm trying the following sample code, and failing (the uid and password I'm using
I'm failing to send a XML file named filesystem.xml to CouchDB using curl on
Google/MyBrain are failing me. Without using a framework (which I'll never get past my
Using this code: var pendingRequest = new Ajax.Request(myUrl, { method: 'post', postBody: soapMsg, contentType:
I am trying to use Twitter OAuth and my POST requests are failing with
I am doing a little learning on php and and html using smarty to
Hi I'm having an issue with using jquery overlays failing to close when my
I have a WCF Service hosted in IIS/ASP.NET that accepts HTTP Post ( not
Very simple spec... @post.user.should == @user Spec fails even though both objects are identical

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.