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

  • Home
  • SEARCH
  • 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 9082571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:35:25+00:00 2026-06-16T20:35:25+00:00

I have built a custom api using php, its a simple api that works

  • 0

I have built a custom api using php, its a simple api that works by posting xml data.
The code that I have working to post to the api is:

<?php 
$xml_data = '<document>
 <first>'.$first.'</first>
 <last>'.$last.'</last>
 <email>'.$email.'</email>
 <phone>'.$phone.'</phone>
 <body>TEST</body>
</document>';
        $URL = "url";
        $ch = curl_init($URL);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);
        curl_close($ch);
        $Response = curl_exec($ch);    
    curl_close($ch);
    echo "Responce= ".$responce;
?>

On the other side, the code the above posts to:

<?php 
$postdata = file_get_contents("php://input"); 
$xml = simplexml_load_string($postdata);
$first = $xml->first;
$last = $xml->last;
$email = $xml->email;
$phone = $xml->phone;
?>

Then I take those php variables and send to a database.. ALL THIS CODE IS WORKING!!

But my questions is: How do I send a response back to the posting side?
How do I use curl_init to send to curl_exec?

Any help would be great! Thank you
Jason

  • 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-06-16T20:35:27+00:00Added an answer on June 16, 2026 at 8:35 pm

    I think you want:

     echo "Responce= ".$Response;
                       ^^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a custom hashmap using two arrays. One contains keys another values.
I have built a custom membership provider that I have used in a previous
I have built a custom component using some containers and a TileList. Now when
I have a custom built application framework written in PHP which I have been
I have a custom component built for a Joomla 2.5 website. It is working
I have built a variety of little scripts using Ruby's very simple Queue class,
I'm shifting code from an application built in a non-standard custom PHP framework into
I have built a Facebook app using OpenGraph that permits the users to write
I have a custom application that was built to send opt-in newsletters and marketing
I have built a Custom MaskedTextBox , changing the values of BeepOnError and AsciiOnly

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.