New API Dev problems

So I’m trying to figure out how to create an api to act as a go between some management software and a credit card processor. The situation is I click checkout on a shopping cart. This uses a link I provide to the api I’m developing. I need the API to get the info from the shopping cart then format it to send to the credit card processor to handle the payment.

The problem I’ve been having is getting that info from the cart. It either comes up without the info or the page doesn’t load. As in I click the checkout button and the page doesn’t change.
I this got something from file_get_contents('php://input'); before but I don’t remember what it was exactly.

Using something like this is giving me problems.
$jsonPOST = file_get_contents('php://input');
$jsonArray = json_decode($jsonPOST, true);
Testing it initially worked but now it doesn’t. Trying a raw dump ends up with an empty string.
var_dump( file_get_contents('php://input'));

Also, I’m working in a subfolder instead of the root directory. So the url would be I’ve got an htaccess file that contains this:
RewriteEngine On
RewriteRule . index.php

Well, I can answer the first part.

/* Get $_POST data being sent from JavaScript and Decodes it */
$data = json_decode(file_get_contents('php://input'), true);

For example this is just the first object in JavaScript Format

0: Object { id: 165, user_id: 2, date_taken: “June 14, 2022”, … }
converts it to PHP format.


The problem I was getting was it was empty. Trying to decode nothing could prevent the php script from running. From what I saw, it most likely was the source server being changed so it no longer provided anything.

Luckily, we were able to transfer the issue to the people working on the server so I no longer have to bang my head against this wall.

Sponsor our Newsletter | Privacy Policy | Terms of Service