Hi,
Thanks for this great mod. It works fine on new created products, however, we often use copy to create new products. If we copy a product it isn't send to twitter. is there a solution for this?
Hi,
Thanks for this great mod. It works fine on new created products, however, we often use copy to create new products. If we copy a product it isn't send to twitter. is there a solution for this?
Zen cart installation / maintenance / customisation / hosting
Supported Modules: Dutch language pack, Multi site, Dynamic Price Updater and more.
Problem solved
I copied all the stuff between start autoTweet 3.0 and eof autotweet to some rule below (see part of code)
PHP Code:$sql_data_array = array_merge($sql_data_array, $update_sql_data);
zen_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");
// reset products_price_sorter for searches etc.
zen_update_products_price_sorter((int)$products_id);
///////////////////////////////////////////////////////
//// INSERT PRODUCT-TYPE-SPECIFIC *UPDATES* HERE //////
// start autoTweet 3.0
//User Settings.
$consumerKey = "xxxxxx"; //twitter app consumer key.
$consumerSecret = "xxxxxx"; //twitter app consumer secret.
$oauthToken = "xxxxxx"; //twitter app "my access" token
$oauthTokenSecret = "xxxxxx"; //twitter app "my access" token secret.
$bitlyUsername = "xxxxx"; //bit.ly username
$bitApiKey = "xxxxx"; //bit.ly api key.
$storeUrl = "xxxxx"; //url to the homepage of your store.
$showprice = 0; // Show the product price? 0 = off, 1 = on. no quotes.
Zen cart installation / maintenance / customisation / hosting
Supported Modules: Dutch language pack, Multi site, Dynamic Price Updater and more.
Hi all
How hard would this be to create a checkbox within the product details page to post that product onto twitter?
My issues;
1. We add products and leave them offline while waiting for stock to arrive. These are autotweeted and we have to go and delete the tweet.
2. Sometimes old products are edited (new style or type) so we would like to tweet again.
3. Some products are added to hidden sections for newsletter subscribers only, these automatically get posted and we have to go deleting them.
Kind Regards
Dave
Hi,
I need some help I have added the autotweet module but I doesn't function? I don't get any errors when I add a product?
This is the code that I have put in I have change the key's and passwords for security but I wanted to check the basics are right.
// start autoTweet 3.0
//User Settings.
$consumerKey = "0gWLhuXHSzdImWWo9gE9qg"; //twitter app consumer key.
$consumerSecret = "0GiGSTVSwdhQEk9mr26dIkGgzSagwSy0yLz9KQ"; //twitter app consumer secret.
$oauthToken = "247733275-bwLM6B7o925J8f4ZPKWpoOfCGggz6HAtNUS8KuDU"; //twitter app "my access" token
$oauthTokenSecret = "NzrnYbuqv9LosZ1kwx9aWkgFSx4xdfDVYzVZZv7Xs4Y"; //twitter app "my access" token secret.
$twitUsername = "mobilegearuk";
$twitPassword = "******";
$bitlyUsername = "mobilegearuk"; //bit.ly username
$bitApiKey = "R_4c7acc2b6a341dfdf796fa414dd877f46"; //bit.ly api key.
$storeUrl = "http://www.mobile-gear.co.uk"; //url to the homepage of your store.
$showprice = 0; // Show the product price? 0 = off, 1 = on. no quotes.
$timeout = 10; //seconds to wait for twitter & bit.ly. This can be left alone.
//do not edit below this line.
Should I be able to see the module in my admin section under modules and do I need to turn it on?
Thanks in advance
Nick
Nick
I'm no expert but have this working, here is a copy of mine, try modifying this with your data.
Code:// start autoTweet 3.0 //User Settings. $consumerKey = "xxxxxxxxxxxxxxx"; //twitter app consumer key. $consumerSecret = "xxxxxxxxxxxxxx"; //twitter app consumer secret. $oauthToken = "xxxxxxxxxxxxxxxxx"; //twitter app "my access" token $oauthTokenSecret = "xxxxxxxxxxxxxxxx"; //twitter app "my access" token secret. $bitlyUsername = "bitly2011"; //bit.ly username $bitApiKey = "R_8888888888888888888888883"; //bit.ly api key. $storeUrl = "www.domain.co.uk"; //url to the homepage of your store no http. $showprice = 0; // Show the product price? 0 = off, 1 = on. no quotes. $timeout = 10; //seconds to wait for twitter & bit.ly. This can be left alone. //do not edit below this line. $prodUrl = urlencode(zen_catalog_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_id)); //short url function. function shortenUrl($user, $key, $shortenUrl){ $url = 'http://api.bit.ly/v3/shorten?login=' . $user .'&apiKey='. $key . '&longUrl=' . $shortenUrl . '&format=xml'; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, $timeout); $data = curl_exec($ch); curl_close($ch); return $data; } //use oAuth library require_once 'twitteroauth/twitteroauth.php'; //function to shorten url $shorten = shortenUrl($bitlyUsername, $bitApiKey, $prodUrl); //start message w/ or w/out price $message = "New product available: " . $_POST['products_name'][$_SESSION['languages_id']] . '!'; if ($showprice){ $message .= ' Only $' . $products_price . '.'; } //if shorten fails use $storeUrl $bitStatus = simplexml_load_string($shorten); $http_code = $bitStatus->status_code; $status_txt = $bitStatus->status_txt; if ($http_code != 200){$shorten = $storeUrl; $biterror = "URL was not shortened for Twitter: "; $biterror .= $storeUrl . " was used instead."; $biterror .= " Reason: " . $status_txt; $messageStack->add_session($biterror, 'caution'); } else { $shorten = $bitStatus->data->url;} //finish message. $message .= ' Check it out now at ' . $shorten; //the connection to twitter API $connection = new TwitterOAuth($consumerKey, $consumerSecret, $oauthToken, $oauthTokenSecret); $connection->timeout = $timeout; $connection->connecttimeout = $timeout; //send message $tweet = $connection->post('statuses/update', array('status' => $message)); //error check if ($connection->http_code != NULL){ if ($connection->http_code != 200){ $error = "Twitter could not be updated: " . $connection->http_header["status"] . ": "; $error .= $tweet->error; $error .= "<br />To paste the code into twitter yourself use: <br />" . $message; $messageStack->add_session($error, 'error'); } else { $messageStack->add_session('Twitter Updated!', 'success'); } } else { $error = "Twitter could not be updated: Could not connect or there was nothing to do once connected.<br /> Twitter may be down or over capacity. To paste the code into twitter yourself use: <br />"; $messageStack->add_session($error, 'error'); $messageStack->add_session($message, 'caution'); } // end autoTweet 3.0
Regards Dave