I have this portion of code:
public function setAction($action, $params = array()) {
$actionUri = strtolower($action);
$zanoxAuth = new ApiAuthorization();
$zanoxAuth->setConnectId(__ZANOX_CONNECT_ID);
$zanoxAuth->setSecretKey(__ZANOX_SECRET_KEY);
/*
* Default number of items in the JSON
* response
*/
$defaultResults = __ZANOX_JSON_DEFAULT_RESULTS;
$zanoxAuth->setTimestamp(gmdate("D, d M Y H:i:s T"));
$timestamp = $zanoxAuth->getTimestamp();
$nonce = $zanoxAuth->getNonce();
/*
* Uri queries concatenation
*/
$queries = '';
if (is_array($params) && count($params) > 0)
foreach ($params as $param => $value)
$queries .= "&$param=$value";
/*
* Getting the first page of the JSON
* response.
*/
$results = $this->curlMe(__ZANOX_ENDPOINT . "$actionUri", "?connectid=" . __ZANOX_CONNECT_ID . "$queries&page=0&items=$defaultResults&date=$timestamp&nonce=$nonce&signature=" . $zanoxAuth->getSignature('GET/', $action, $nonce));
$results = json_decode($results);
/*
* Checking if there are more items to get
* by looping the pages.
*/
if ($results->total > $defaultResults) {
$pages = ceil($results->total / $defaultResults);
for ($i = 1; $i < $pages; $i++) {
$nonce = $zanoxAuth->getNonce();
$addJSON = $this->curlMe(__ZANOX_ENDPOINT . "$actionUri", "?connectid=" . __ZANOX_CONNECT_ID . "$queries&page=$i&items=$defaultResults&date=$timestamp&nonce=$nonce&signature=" . $zanoxAuth->getSignature('GET/', $action, $nonce));
$addJSON = json_decode($addJSON);
/*
* Adding JSON items to the main one.
*/
foreach ((array) $addJSON->programApplicationItems->programApplicationItem as $newItem)
$results->programApplicationItems->programApplicationItem[] = $newItem;
}
}
$this->action = $results;
return $this;
}
Where you see $results->programApplicationItems->programApplicationItem[] = $newItem; I would like to pass the params of the object as a variable, such as:
$results->$action . "Items"->$action . "Item"[] = $newItem
Obviously the above do not work.
I thought about var_dump or var_export but I am not sure they are going to work.
Any help?
Thank you very much.