Public Function post_tweet ($ tweet_text) {include_once ('twitter/tmhoauth. PHP '); // tmhoauth. PHP is a Twitter API and put it under/lib/Twitter. read $ connection = new tmhoauth (Array ('consumer _ key' => 'xrnoml0zzk ...... ', 'consumer _ secret' => 'xfdubpvnj8ljhksax8n9ggsp ...... ', 'user _ token' => 'c9796070-zwyrdlkswm40ssyx0woxy ...... ', 'user _ secret' => 'vdlvawikcml9a9ruxgsarlhjmin ...... ',); // make the API call $ connection-> request ('post', $ connection-> URL ('1/statuses/Update '), array ('status' => $ tweet_text); return $ connection-> response ['code'];}
Instance demand: My magento station will launch a special product every day. At the same time, I want to automatically publish the relevant information of this product to my Twitter to achieve more
People are concerned about the effects of this product and my sites.
Add the following code in helper/data. php:
The above consumer_key, user_token and other parameters will open a new article later on how to register and obtain them.
Then you can use the above function to synchronously update your Twitter. The Code is as follows:
$ Twitter = "product information, such as name and price"; $ return_code = Mage: helper ('yourmode')-> post_tweet ($ Twitter );
Log on to your Twitter account and check that the information has been published!
Tmhoauth. php: http://download.csdn.net/download/shangxiaoxue/3972615
Original article. For more information, see the source!