Ok so i have a curl request I am trying to make.
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://someurl.com/shop_pos/index.php?route=module/cart/ajax_get_all_products");
// Do a POST
$items =
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_SESSION['cart']);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
The contents or $_SESSION['cart'] is
Array
(
[155] => 1
[78] => 1
)
I need to send this data either as post data or a get variable…any suggestions
on the catching function
public function ajax_get_all_products(){
$this->language->load('module/cart');
$all_products = $this->cart->getProducts();
$data_returned = json_encode($all_products);
echo "<pre>".print_r($_REQUEST, true)."</pre>";
echo "<pre>".print_r($_POST, true)."</pre>";
$this->response->setOutput($data_returned, $this->config->get('config_compression'));
}
I dont get the array I set over. The two files are on the same server btw
try:
try this: