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 8233065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:00:41+00:00 2026-06-07T18:00:41+00:00

I have a small PHP script that is listening for a POST request. I’m

  • 0

I have a small PHP script that is listening for a POST request. I’m expecting xml, always.
Normally I’m the guy sending the xml requests. But today I’m on the receiving side.

I figured it would be a simple case of listening for a $_POST, but I guess I may be incorrect – I’m getting nothing.

Here’s my script that waits for anything xml:

<?php
if(isset($_POST)) {
    mail("me@myemail.com","some title i want", print_r($_POST, true)); 
}else{
    die("uh, what happened?");
}
?>

And here is a simple xml string I’m sending from another place:

<?php
$xml_data ='
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don\'t forget me this weekend!</body>
</note>
';

function sendXML2Server($URL,$XML){
    $xml_data = trim($XML);
    $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_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);

    return $output;
}

echo sendXML2Server('https://someurl.com/inboundxml.php',$xml_data)
?>

And here’s what I get in my email:

Array
(
)

I’m guessing I’m not working with an array correctly, but maybe there’s something else I’m missing in all this. I’m expecting to get back the actual xml string.

  • 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-07T18:00:44+00:00Added an answer on June 7, 2026 at 6:00 pm

    You sending nothing but data, thats why PHP cannot interpreter this data as some key&value. So, you need to send it as a value of variable:

    curl_setopt($ch, CURLOPT_POSTFIELDS, array('xml_data' => $xml_data));
    

    or receive as a raw post data:

    <?php
    if(isset($HTTP_RAW_POST_DATA)) {
        mail("me@myemail.com","some title i want", print_r($HTTP_RAW_POST_DATA, true)); 
    }else{
        die("uh, what happened?");
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this small PHP script that takes a POST variable and writes it
So I have a small PHP script that generates an xml feel for the
I have nginx receiving POST requests and a tiny PHP script that puts request
We have a small php script, that displays random adverts on our site .
I have a problem with my index.php, i have this small script that decides
I have a small problem with a script that reads an XML file and
I have a small PHP script that takes the values from a dropdown list
I have a small PHP script that is selecting a random sentence from an
I have created a small php script locally that runs a java application in
I have a small script which im using to test PHP mail(), as below:

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.