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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:51:39+00:00 2026-06-10T03:51:39+00:00

I have a form that sends the information to an api and gets a

  • 0

I have a form that sends the information to an api and gets a response in XML format. I need to know what the best way to document/parse the results (text document, or anything else). If possible i would like the responses to all save into one document and not single documents for every result.

i’m using an ajax post method and the localproxy code where the results code needs to be is below

<?php
$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_URL, 'http://integrate.com/api/test.ashx'); 
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_POSTFIELDS, $_POST);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
curl_close($ch);

file_put_contents('mydata.xml', $result, FILE_APPEND);

die('<h1>Thanks!</h1>');

?>

the xml data comes in the format below

<result>
<success>0</success>
<leadid/>
<errors>
<error>Missing Field: </error>
</errors>
</result>

The file gets created and has content in it now, this is the content, it is an error

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">

<HTML><HEAD><TITLE>Bad Request</TITLE>

<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>

<BODY><h2>Bad Request - Invalid Content Length</h2>

<hr><p>HTTP Error 400. There is an invalid content length or chunk length in the request.</p>

</BODY></HTML>

what does this mean? the api server isn’t accepted the request?

  • 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-10T03:51:41+00:00Added an answer on June 10, 2026 at 3:51 am

    As for parsing xml, use XML parser

    To save the result in a file, appending each result to the end of the file you could use file_put_contents($filename, $data, FILE_APPEND)

    e.g.

    <?php
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, 'http://integrate.com/api/test.ashx');
    curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
    curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec ($ch);
    curl_close($ch);
    file_put_contents('mydata.xml', $result, FILE_APPEND);
    ?>
    

    If you need to send a post request add:

    curl_setopt ($ch, CURLOPT_POSTFIELDS, 'param=value&param=value'); // to be replace with valid query string
    curl_setopt ($ch, CURLOPT_POST, 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that sends money value e.g <input type=text name=amount value=N50,000.00 NGN
I have a form that sends info into a database table. I have it
I have a php form that saves the info to my database and sends
I have a contact page (contact.php) that sends a form (formsend.php) when people fill
A theoretically question: I have a C# Windows Form app, that sends back some
I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down
Hi I have a web form that sends a string to one php file
I have an HTML form that takes inputted data and sends it via the
I have a form that emails information and am trying to add another person
I have a form that sends out a notification when a client fills out

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.