Up until Magento 1.7 I was able to use the following code to add a product to cart programatically:
require_once '../app/Mage.php';
Mage::getSingleton('core/session', array('name' => 'frontend'));
umask(0);
Mage::app();
$session = Mage::getSingleton('customer/session');
$product = Mage::getModel('catalog/product')->load(99); // Random product ID
// get cart and add product
$cart = Mage::getSingleton('checkout/cart');
$cart->init();
$cart->addProduct($product, 1);
// update session
$session->setCartWasUpdated(true);
// save the cart
$cart->save();
However, this does not work anymore in Magento 1.8. I've been trying/searching all day why this is the case. Sadly I haven't found any clue regarding this issue.
It may have to do with the changes in 1.8 which also causes the requirement for a form-key when using the URL method; this is a wild guess though.
Anyone any idea or a working example on how to do this when working with Magento 1.8?