Page 22 of 23 FirstFirst ... 1220212223 LastLast
Results 211 to 220 of 230
  1. #211
    Join Date
    Jan 2005
    Posts
    101
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    thanks for this great module.

    can you add http://adf.ly API in this module at this time you use bitly.com API

    if any one help me.

    code:

    -------------------------------------------------------------------------------------

    <?php
    /**
    * @package admin
    * @copyright Copyright 2003-2010 Zen Cart Development Team
    * @copyright Portions Copyright 2003 osCommerce
    * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
    * @version $Id: update_product.php 15636 2010-03-07 07:00:40Z drbyte $
    */
    if (!defined('IS_ADMIN_FLAG')) {
    die('Illegal Access');
    }
    if (isset($_GET['pID'])) $products_id = zen_db_prepare_input($_GET['pID']);
    if (isset($_POST['edit_x']) || isset($_POST['edit_y'])) {
    $action = 'new_product';
    } elseif ($_POST['products_model'] . $_POST['products_url'] . $_POST['products_name'] . $_POST['products_description'] != '') {
    $products_date_available = zen_db_prepare_input($_POST['products_date_available']);

    $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';

    // Data-cleaning to prevent MySQL5 data-type mismatch errors:
    $tmp_value = zen_db_prepare_input($_POST['products_quantity']);
    $products_quantity = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;
    $tmp_value = zen_db_prepare_input($_POST['products_price']);
    $products_price = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;
    $tmp_value = zen_db_prepare_input($_POST['products_weight']);
    $products_weight = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;
    $tmp_value = zen_db_prepare_input($_POST['manufacturers_id']);
    $manufacturers_id = (!zen_not_null($tmp_value) || $tmp_value=='' || $tmp_value == 0) ? 0 : $tmp_value;

    $sql_data_array = array('products_quantity' => $products_quantity,
    'products_type' => zen_db_prepare_input($_GET['product_type']),
    'products_model' => zen_db_prepare_input($_POST['products_model']),
    'products_price' => $products_price,
    'products_date_available' => $products_date_available,
    'products_weight' => $products_weight,
    'products_status' => zen_db_prepare_input((int)$_POST['products_status']),
    'products_virtual' => zen_db_prepare_input((int)$_POST['products_virtual']),
    'products_tax_class_id' => zen_db_prepare_input((int)$_POST['products_tax_class_id']),
    'manufacturers_id' => $manufacturers_id,
    'products_quantity_order_min' => zen_db_prepare_input($_POST['products_quantity_order_min']),
    'products_quantity_order_units' => zen_db_prepare_input($_POST['products_quantity_order_units']),
    'products_priced_by_attribute' => zen_db_prepare_input($_POST['products_priced_by_attribute']),
    'product_is_free' => zen_db_prepare_input((int)$_POST['product_is_free']),
    'product_is_call' => zen_db_prepare_input((int)$_POST['product_is_call']),
    'products_quantity_mixed' => zen_db_prepare_input($_POST['products_quantity_mixed']),
    'product_is_always_free_shipping' => zen_db_prepare_input((int)$_POST['product_is_always_free_shipping']),
    'products_qty_box_status' => zen_db_prepare_input($_POST['products_qty_box_status']),
    'products_quantity_order_max' => zen_db_prepare_input($_POST['products_quantity_order_max']),
    'products_sort_order' => (int)zen_db_prepare_input($_POST['products_sort_order']),
    'products_discount_type' => zen_db_prepare_input($_POST['products_discount_type']),
    'products_discount_type_from' => zen_db_prepare_input($_POST['products_discount_type_from']),
    'products_price_sorter' => zen_db_prepare_input($_POST['products_price_sorter'])
    );

    // when set to none remove from database
    // is out dated for browsers use radio only
    $sql_data_array['products_image'] = zen_db_prepare_input($_POST['products_image']);
    $new_image= 'true';

    if ($_POST['image_delete'] == 1) {
    $sql_data_array['products_image'] = '';
    $new_image= 'false';
    }

    if ($_POST['image_delete'] == 1) {
    $sql_data_array['products_image'] = '';
    $new_image= 'false';
    }

    if ($action == 'insert_product') {
    $insert_sql_data = array( 'products_date_added' => 'now()',
    'master_categories_id' => (int)$current_category_id);

    $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

    zen_db_perform(TABLE_PRODUCTS, $sql_data_array);
    $products_id = zen_db_insert_id();

    // reset products_price_sorter for searches etc.
    zen_update_products_price_sorter($products_id);

    $db->Execute("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . "
    (products_id, categories_id)
    values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");

    ///////////////////////////////////////////////////////
    //// INSERT PRODUCT-TYPE-SPECIFIC *INSERTS* HERE //////


    // start autoTweet 3.0
    //User Settings.
    $consumerKey = "Your twitter app consumer key"; //twitter app consumer key.
    $consumerSecret = "Your twitter app consumer secret"; //twitter app consumer secret.
    $oauthToken = "Your my access oauth token"; //twitter app "my access" token
    $oauthTokenSecret = "Your my access oauth token secret"; //twitter app "my access" token secret.
    $bitlyUsername = "your bitly username"; //bit.ly username
    $bitApiKey = "Your bitly API key"; //bit.ly api key.
    $storeUrl = "www.your-store.com"; //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.
    $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



    //// *END OF PRODUCT-TYPE-SPECIFIC INSERTS* ////////
    ///////////////////////////////////////////////////////
    } elseif ($action == 'update_product') {
    $update_sql_data = array( 'products_last_modified' => 'now()',
    'master_categories_id' => ($_POST['master_category'] > 0 ? zen_db_prepare_input($_POST['master_category']) : zen_db_prepare_input($_POST['master_categories_id'])));

    $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 //////


    //// *END OF PRODUCT-TYPE-SPECIFIC UPDATES* ////////
    ///////////////////////////////////////////////////////
    }

    $languages = zen_get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
    $language_id = $languages[$i]['id'];

    $sql_data_array = array('products_name' => zen_db_prepare_input($_POST['products_name'][$language_id]),
    'products_description' => zen_db_prepare_input($_POST['products_description'][$language_id]),
    'products_url' => zen_db_prepare_input($_POST['products_url'][$language_id]));

    if ($action == 'insert_product') {
    $insert_sql_data = array('products_id' => $products_id,
    'language_id' => $language_id);

    $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

    zen_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);

    } elseif ($action == 'update_product') {
    zen_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
    }
    }

    // add meta tags
    $languages = zen_get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
    $language_id = $languages[$i]['id'];

    $sql_data_array = array('metatags_title' => zen_db_prepare_input($_POST['metatags_title'][$language_id]),
    'metatags_keywords' => zen_db_prepare_input($_POST['metatags_keywords'][$language_id]),
    'metatags_description' => zen_db_prepare_input($_POST['metatags_description'][$language_id]));

    if ($action == 'insert_product_meta_tags') {

    $insert_sql_data = array('products_id' => $products_id,
    'language_id' => $language_id);

    $sql_data_array = array_merge($sql_data_array, $insert_sql_data);

    zen_db_perform(TABLE_META_TAGS_PRODUCTS_DESCRIPTION, $sql_data_array);
    } elseif ($action == 'update_product_meta_tags') {
    zen_db_perform(TABLE_META_TAGS_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
    }
    }


    // future image handler code
    define('IMAGE_MANAGER_HANDLER', 0);
    define('DIR_IMAGEMAGICK', '');
    if ($new_image == 'true' and IMAGE_MANAGER_HANDLER >= 1) {
    $src= DIR_FS_CATALOG . DIR_WS_IMAGES . zen_get_products_image((int)$products_id);
    $filename_small= $src;
    preg_match("/.*\/(.*)\.(\w*)$/", $src, $fname);
    list($oiwidth, $oiheight, $oitype) = getimagesize($src);

    $small_width= SMALL_IMAGE_WIDTH;
    $small_height= SMALL_IMAGE_HEIGHT;
    $medium_width= MEDIUM_IMAGE_WIDTH;
    $medium_height= MEDIUM_IMAGE_HEIGHT;
    $large_width= LARGE_IMAGE_WIDTH;
    $large_height= LARGE_IMAGE_HEIGHT;

    $k = max($oiheight / $small_height, $oiwidth / $small_width); //use smallest size
    $small_width = round($oiwidth / $k);
    $small_height = round($oiheight / $k);

    $k = max($oiheight / $medium_height, $oiwidth / $medium_width); //use smallest size
    $medium_width = round($oiwidth / $k);
    $medium_height = round($oiheight / $k);

    $large_width= $oiwidth;
    $large_height= $oiheight;

    $products_image = zen_get_products_image((int)$products_id);
    $products_image_extension = substr($products_image, strrpos($products_image, '.'));
    $products_image_base = preg_replace('/'.$products_image_extension.'/', '', $products_image);

    $filename_medium = DIR_FS_CATALOG . DIR_WS_IMAGES . 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . '.' . $fname[2];
    $filename_large = DIR_FS_CATALOG . DIR_WS_IMAGES . 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . '.' . $fname[2];

    // ImageMagick
    if (IMAGE_MANAGER_HANDLER == '1') {
    copy($src, $filename_large);
    copy($src, $filename_medium);
    exec(DIR_IMAGEMAGICK . "mogrify -geometry " . $large_width . " " . $filename_large);
    exec(DIR_IMAGEMAGICK . "mogrify -geometry " . $medium_width . " " . $filename_medium);
    exec(DIR_IMAGEMAGICK . "mogrify -geometry " . $small_width . " " . $filename_small);
    }
    }

    zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . (isset($_POST['search']) ? '&search=' . $_POST['search'] : '') ));
    } else {
    $messageStack->add_session(ERROR_NO_DATA_TO_SAVE, 'error');
    zen_redirect(zen_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id . (isset($_GET['page']) ? '&page=' . $_GET['page'] : '') . (isset($_POST['search']) ? '&search=' . $_POST['search'] : '') ));
    }

    -------------------------------------------------------------------------------------

  2. #212
    Join Date
    Jan 2012
    Location
    New England
    Posts
    243
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    I am having trouble... Running ZC 1.5.0 and installed the newest version of AutoTweet.. but when I make a new product I get this:


    URL was not shortened for Twitter: www.opalessenceshop.com was used instead. Reason: INVALID_LOGIN
    Twitter could not be updated: 401 Unauthorized: Could not authenticate you.
    To paste the code into twitter yourself use:
    New product available: Natural Vanilla Flavored Lip Balm .15oz! Only $3.07. Check it out now at www.opalessenceshop.com

    Now, my file was not as described in the readme file:

    The readme file says it will be like this:

    Now edit lines 96 through 100 like so:
    a. $twitUsername = your twitter user name.
    b. $twitPassword = your twitter password.
    c. $bitlyUsername = your bit.ly user name (available for free at www.bit.ly)
    d. $bitApiKey = your bit.ly API Key, find it by logging in to bit.ly and clicking settings.
    Mine looked like this:

    Now edit lines 96 through 100 like so:
    $oauthToken = "Enter oauthToken here"; //twitter app "my access" token
    $oauthTokenSecret = "Enter oauthTokenSecret here"; //twitter app "my access" token secret.
    $bitlyUsername = "your bit.ly user name"; //bit.ly username
    $bitApiKey = "your bit.ly API Key"; //bit.ly api key.
    So I'm not sure what to do... can anyone help?

  3. #213
    Join Date
    Jan 2012
    Location
    New England
    Posts
    243
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    Ok I got the thing to tweet to twitter, but it still says

    URL was not shortened for Twitter: www.opalessenceshop.com was used instead. Reason: INVALID_LOGIN

    I have reset my bit.ly API key, so I know that's right... I think my username is OpalEssenceShop... at the top of the page it says, for example, "@OpalEssenceShop Account Settings" (at https://bitly.com/a/account) so what is going wrong?

    And treefrog, how did you get it to tweet on update with an option to not tweet? I'd really like that, because a lot of times I add products when I have time, ahead of when they're actually ready to sell, then make the product and go in and change the status of the product or change the quantity from 0 to 5 or whatever--and I'd like to tweet it *then*...

  4. #214
    Join Date
    Jul 2010
    Posts
    101
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    Hey folks! I added this mod earlier today and I was getting the 401 error like many of you are. I did 2 things to fix it. I'm not sure which one was the cure.

    1. I created a new app and used the new #'s it gave me for the code

    2. for some reason when I copied and pasted from the Twitter developer page, there were extra spaces after " and the beginning of the auth codes. I deleted the space.

    The app works perfectly now I just wish there was a way to turn it off and on.

  5. #215
    Join Date
    Jan 2012
    Location
    New England
    Posts
    243
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    2 questions:

    1) I tried following the directions here: http://www.zen-cart.com/showthread.p...322#post996322 but replacing stuff with "twitter" but it didn't work... in an ideal world I would have both AutoFacebook and AutoTweet at the bottom of the page and with yes/no checkboxes... could someone who knows how to code better than me (just about any 3rd grader, for example) tell me where exactly to move my AutoTweet* and AutoFacebook code to in the page, and verify/fix the checkboxes thing so that it works?

    2) More of a cosmetic thing, but when it sends a tweet with my new products, it lists their price with four decimal places. For example "$3.1200" ...is there something I can tweak to fix that? It just looks silly.


    *I already have my AutoTweet code near the bottom of the page, and it tweets on add AND update, but I want to be able to turn it off if I'm making lots of small changes so I don't flood my stream. When I moved AutoFacebook to the same area, it all broke.

  6. #216
    Join Date
    Jan 2012
    Location
    New Jersey
    Posts
    75
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    I am installing the Auto-tweet mod and have a question regarding how to set up the twitter dev app. The website and callback are the 2 questions that I am uncertain how to answer. The Zencart 1.50 site url is: store.bbiclan.com, and my twitter account is @TheMortician4. What inputs should I place in these pages?

  7. #217
    Join Date
    Jun 2012
    Posts
    24
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    how come my url for my site isnt working?
    i even used www.

  8. #218
    Join Date
    Jun 2012
    Posts
    24
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    ........

  9. #219
    Join Date
    Jun 2012
    Posts
    24
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    never mind staring over worked

  10. #220
    Join Date
    Dec 2007
    Posts
    94
    Plugin Contributions
    0

    Default Re: AutoTweet [support]

    Is anybody else experiencing problems, I havent put any new products on since April and now it doesnt seem to work, no errors that I can see, is it just me or has something changed with Bit:ly??

 

 
Page 22 of 23 FirstFirst ... 1220212223 LastLast

Similar Threads

  1. PHP 5.3 Support on 1.3.7
    By DogTags in forum General Questions
    Replies: 3
    Last Post: 4 Aug 2010, 03:53 PM
  2. PHP 5.3 Support for v1.3.8/a
    By DrByte in forum Zen Cart Release Announcements
    Replies: 2
    Last Post: 9 Nov 2009, 08:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •