Automatically publish products on Twitter

With the following PHP script, when we add new product in Zen Cart, it will automatically publish the product on Twitter.

(It can be added to /admin/includes/modules/update_product.php )

// BOF twitter feed
    if ($action == 'insert_product')
      $purl = zen_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id);
      $tinyPurl = file_get_contents(''.$purl);
      function updateStatus($user, $password, $message)
        $url = "";
        $curl = curl_init($url);
        $data = array('status'=>$message);
        curl_setopt($curl, CURLOPT_USERPWD, $user.':'.$password);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:'));
        $result = @curl_exec($curl);
        return $result;
      $message = STORE_NAME . ' has a new product. ' . $tinyPurl;
      $user = 'YYYYYYYYY';
      $password = 'XXXXXXXXX';
      $result = updateStatus($user, $password, $message);
      $messageStack->add_session($result, 'error');
    // EOF twitter feed

Leave a Reply

Your email address will not be published. Required fields are marked *