Hi everyone, I am working on a wee small project using cURL.
From the documentation, it states
"The Server will HTTP POST a string in a parameter called (INCOMING)" to the given callback URL.

I know the list of parameters in the string as this is given in the documentation,
What I dont know how to do, is "echo" the value(s) of each parameter in the string.

I have tried using _POST

foreach($_POST as $key=>$value){
    echo $key, ' => ', $value, "<br/>\n";
}

$QueryID = $_POST['QueryID'];

if($QueryID) {
    echo '<p/>QueryID: ', $QueryID, "<br/>\n";
}

else {
    echo '<p>No ID parameter.</p>';
}

I have also tried using _GET

foreach($_GET as $key=>$value){
    echo $key, ' => ', $value, "<br/>\n";
}

$QueryID = $_GET['QueryID'];

if($QueryID) {
    echo '<p/>QueryID: ', $QueryID, "<br/>\n";
}

else {
    echo '<p>No ID parameter.</p>';
}

But I keep getting "No ID parameter"....
If someone could show me how to do this, I would be forever greatful :)

Hope someone can help...

Dani AI

Generated

reported that the remote system will POST a string in a parameter called INCOMING, but var_dump($_POST) and foreach($_POST) showed nothing. The common cause here is a mismatch between how the sender formats the request and what PHP auto-parses into $_POST. As noted, cURL used as a client returns data to the calling script (it does not populate $_POST); conversely, when acting as the receiver, PHP will only fill $_POST if the request uses standard form encoding. If the sender posts raw text or JSON, $_POST can be empty even though data arrived.

A short checklist to diagnose the problem:

  • Confirm the callback URL is the exact URL the sender is using and the server actually receives the request (check access logs).
  • Log request method, headers and the raw request body to see what arrives and what Content-Type is set.
  • If $_POST is empty, read php://input and inspect it. If INCOMING itself contains a URL-encoded string (e.g. "a=1&b=2"), parse that with parse_str. If the body is JSON, use json_decode.
  • Keep logging to a file while debugging (remove later).

Example debug-and-parse approach (writes a JSON line to a log, then extracts INCOMING whether it arrived as form data, raw body, or JSON):

<?php
$log = [
  'time' => date('c'),
  'method' => $_SERVER['REQUEST_METHOD'] ?? '',
  'headers' => function_exists('getallheaders') ? getallheaders() : [],
  'post' => $_POST,
  'raw' => file_get_contents('php://input'),
];
file_put_contents(__DIR__.'/incoming.log', json_encode($log)."\n", FILE_APPEND);

// find INCOMING whether in $_POST, raw urlencoded body, or JSON
$incoming = $_POST['INCOMING'] ?? null;
if (!$incoming) {
  parse_str($log['raw'], $parsed);
  $incoming = $parsed['INCOMING'] ?? ($log['raw'] && ($json = json_decode($log['raw'], true)) ? ($json['INCOMING'] ?? null) : null);
}
if ($incoming) {
  parse_str($incoming, $params);
  echo 'QueryID: ' . htmlspecialchars($params['QueryID'] ?? 'not present');
} else {
  echo 'No INCOMING parameter found';
}

Notes: test with a simple command-line POST to the callback to reproduce (simulate the sender), ensure the sender sets Content-Type appropriately, watch for case-sensitivity of the key name, and beware server rules (mod_security, firewalls) that can block or alter requests. 's pointer to basic docs is fine, but the next step is logging raw headers/body as above to see what actually arrives.

Recommended Answers

All 3 Replies

Hi, I have even tried

    var_dump($_POST);
    var_dump($_GET);
    var_dump($incoming);
    var_dump($INCOMING);

But still no joy in seeing the values of the parameters...
Driving me nuts this....

Member Avatar for Member #120589

cURL can be used to SEND get or post data and the return data is then saved to the curl variable - not returned as post or get.

Here's an example of a straight scrape - without specifying any parameters (post or get):

$url = "http://www.daniweb.com";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$scraped_page = curl_exec($ch);
curl_close($ch);
echo $scraped_page;

Try that as a basis for getting data from a page. Once you get return data, then go at it to send parameters:

For an example of post:

http://davidwalsh.name/curl-post

It's not brilliant, but an example nonetheless.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.