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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:38:18+00:00 2026-05-14T02:38:18+00:00

Im currently working with an API which requires we send our collection details in

  • 0

Im currently working with an API which requires we send our collection details in xml to their server using a post request.

Nothing major there but its not working, so I want to output the sent xml to a txt file so I can look at actually whats being sent!!

Instead of posting to the API im posting to a document called target, but the xml its outputting its recording seems to be really wrong. Here is my target script, note that the posting script posts 3 items, so the file being written should have details of each post request one after the other.

<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

// get the request data...
$payload = '';
$fp = fopen('php://input','r');
$output_file = fopen('output.txt', 'w');
while (!feof($fp)) {
    $payload .= fgets($fp);
    fwrite($output_file, $payload);
}

fclose($fp);
fclose($output_file);
?> 

I also tried the following, but this just recorded the last post request so only 1 collection item was recorded in the txt file, instead of all 3

output_file = fopen('output.txt', 'w');
while (!feof($fp)) {
    $payload .= fgets($fp);
}
fwrite($output_file, $payload);
fclose($fp);
fclose($output_file);

I know im missing something really obvious, but ive been looking at this all morning!

  • 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-14T02:38:18+00:00Added an answer on May 14, 2026 at 2:38 am

    Change

    $output_file = fopen('output.txt', 'w');
    

    to

    $output_file = fopen('output.txt', 'a');
    

    Also, change

    $payload .= fgets($fp);
    

    to

    $payload = fgets($fp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on desktop application which calls third party API. After authorizing against
The system I am currently working on requires some role-based security, which is well
The company I'm currently working for is using Selenium for Uniting-Testing our User Interface.
I'm currently working on an application which will use the bouncy castle api in
I am currently working in iPhone application in which I have used wikitude api.
I am currently working on a simple web application through Google App engine using
I am working on a Reverse Engineering school project, which requires to translate manipulate
Currently i am working on a project , in which in module , the
I'm currently working on a windows application which is entirely model, that is, it
I am currently working on Twitter4j for connecting to Twitter API. As with any

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.