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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:10:14+00:00 2026-05-22T18:10:14+00:00

I am trying to create an in-app purchase store on the iPad. As part

  • 0

I am trying to create an in-app purchase store on the iPad. As part of that system, I use a server to host the IAP content and serve the appropriate assets when given a valid receipt. The way I do this is to have the iPad send an HTTP POST to my server with the body of the post being the receipt data.

Here’s my problem: for some reason, the server interprets the POST request as a GET and for this reason, the php://input is always empty. What’s really weird is that it works on my local development environments (Windows, Apache, PHP 5.3) but not on my shared hosted production server (Linux, Apache, PHP 5.2).

Here is the relevant code from the iPad:

NSURL* url = [[NSURL alloc] initWithScheme:@"http" host: host path: path]; 
NSMutableURLRequest* theRequest = [[NSMutableURLRequest alloc] initWithURL: url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval: 60.0f];
[url release];

[theRequest setHTTPMethod: @"POST"];
[theRequest setValue: @"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-Type"];
NSMutableData* postBody = [[NSMutableData alloc] init];
NSString* receiptString = [self newEncodedString:transaction.transactionReceipt];
[postBody appendData:[receiptString dataUsingEncoding:NSUTF8StringEncoding]];
[receiptString release];
NSString* postLength = [[NSString alloc] initWithFormat: @"%d", [postBody length]];
[theRequest setValue: postLength forHTTPHeaderField: @"Content-Length"];
[postLength release];
[theRequest setHTTPBody: postBody];
[postBody release];

NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
...

And here’s the PHP server code:

$httpRequestBody = '';
$fh = @fopen('php://input', 'r');
if ($fh)
{
    while (!feof($fh)) {
        $s = fread($fh, 1024);
        if (is_string($s)) {
            $httpRequestBody .= $s;
        }
    }
    fclose($fh);
} else {
    $statusCode = 1;
}

The $httpRequestBody ends up being empty on the production server. When I call phpinfo(), the REQUEST_METHOD is a GET. Any help is greatly appreciated!

  • 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-22T18:10:15+00:00Added an answer on May 22, 2026 at 6:10 pm

    Shouldn’t have to do the loop, just do

    $httpRequestBody = file_get_contents('php://input')
    

    But since, as you say, it’s showing up as GET, there will never be any data available by this method, as GET requests do not have a body to read from. There’s only the URL with its query parameters.

    Check that your phone is actually sending a POST, then check if your server is somehow rewriting/redirecting the request into a GET instead. This should all be easily visible in the server’s access log.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create BB application that features the in-app purchase. I followed
I'm trying to create an app that multiple users would log into a server
I am trying to create an app that makes use of the camera on
I am trying to create an app that saves the user's media selections from
I'm trying to create an app (my first) that generates invoices for me. Originally
I'm trying to create an app for Android that simply sends a command to
I am trying to create an app that allows you to go to a
I am trying to create an app that calculates the time difference and the
I am trying to create an app that will obtain the users location via
i'm trying to create an app that would present a form to the user

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.