亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

本地發(fā)布文章到twitter和facebo Twitter OAuth

系統(tǒng) 2761 0

After Twitter introduced mandatory authentication with OAuth, many of the current scripts for posting content to Twitter don’t work anymore.

?

OAuth can be great for more advanced authentication, but for a simple post to twitter script, it seems like a little overkill.

?

In this post you’ll learn how to create a simple script that uses a quick and dirty version of OAuth for posting new tweets to Twitter.

?

How to create a simple script

?

Simplified, Twitter OAuth involves sending both application tokens and user tokens back and forth between your site and Twitter.

?

If you want to authenticate multiple users, you need a full OAuth implementation, but if you only want a script that sends tweets from your site or application, the good news is that all the authentication tokens and keys can be reused, which makes it possible to build a very simple script, as long as you just get the required tokens and keys once .

?

To get the required key and tokens you need to carefully follow the next steps

?

Step 1 – Register your application

?

First you need to register your application at Twitter here . ( http://dev.twitter.com/apps/new )

?

Please notice that you need to log in to Twitter at the start of the Application ?registration process. The account that you’re logging in to, is naturally also the twitter account that you’re application can post tweets to.

?

?

?

?

Filling in the form is pretty straightforward.

?

The only special requirement for our purpose is set Default Access type to “ Read & write ”, so your application is allowed to post tweets to twitter

?

?

Step 2 – Consumer secret and Consumer key

?

When your application is registered by Twitter, you also have all the required keys for your script.

You find the consumer keys here:

?

View Your Applications -> Edit Details

?

The consumer keys can be found at the last part of the page

?

Step 3 – Access token and Access token secret

?

You find the Access token and Access token secret by clicking on the “My Access token” link in the right menu.

When you have the four keys/tokens:

?

Consumer secret

Consumer key

Access token

Access token secret

?

You’re ready to proceed

?

Step 4 – Twitter OAuth class

?

To connect to twitter using OAuth we’ll be using the brilliant Abraham Twitter OAuth class . The Abraham twitter OAuth class has a lot of overhead enabling more advanced authentication than is required for this script. You only need the two files “OAuth.php” ?and “twitteroauth.php”.

?

You can download the two files directly here. ?(或者附件: twitteroauth.zip

?

When you have downloaded the files, and uploaded them on your server, you’re ready for the last step

?

Step 5 – Post to twitter script

?

Having the required access tokens, keys and the Twitter OAuth class, it’s a piece of cake to build a script that posts messages to twitter.

?

You just need to insert the required keys and the path to the twitteroauth.php file in the script below, and then you’re up and running.

?

?

    <?php
$consumerKey    = '<insert your consumer key';
$consumerSecret = '<insert your consumer secret>';
$oAuthToken     = '<insert your access token>';
$oAuthSecret    = '<insert your token secret>';

require_once($_SERVER['DOCUMENT_ROOT'].'/<insert path to twitteroauth>/twitteroauth.php');

// create a new instance
$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);

//send a tweet
$tweet->post('statuses/update', array('status' => 'Hello World'));
?>
  
?

?

Conclusion

?

The process for getting this script up and running might be a little ?complex, but you only have to go through the process once, and then you have a very simple to use script for sending tweets to twitter from a PHP script.

?

?

來源: http://tips4php.net/2010/12/twitter-oauth-the-easy-way-simple-post-to-twitter-script/

?

參考:

https://dev.twitter.com/apps ?(創(chuàng)建apps賬戶)

https://dev.twitter.com/docs/application-permission-model ?(使用文檔)

https://dev.twitter.com/docs/twitter-libraries ?(各種語言的操作開源文件)

?

附件 twitter-full- 提供更多的操作。來源: https://github.com/themattharris/tmhOAuth

?

?

另外還有一個(gè)方法就是利用第三方網(wǎng)站

?

這里推薦 twitterfeed.com ,因?yàn)樗耆赓M(fèi)。

?

創(chuàng)建一個(gè)賬戶以及rss feed 就可以了,他會(huì)定時(shí)提交feed到facebook和twitter。

?

?

?

?

?

本地發(fā)布文章到twitter和facebo Twitter OAuth the easy way – simple post to twitter script


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 日韩www | 久久这里只精品热免费99 | 毛片免费视频播放 | 毛片毛片毛片毛片毛片毛片毛片 | 99中文字幕在线 | 国产一区二区三区久久精品 | 婷婷四房综合激情五月性色 | 两性色午夜视频免费老司机 | 欧美亚洲国产第一页草草 | 一级二级毛片 | 国产69精品久久久久99不卡 | 久久久精品免费热线观看 | 夜夜爽夜夜操 | 久久羞羞 | 国产免费播放一区二区三区 | 日韩免费高清一级毛片在线 | 奇米影视第四色首页 | 久久99国产亚洲高清观看韩国 | 日韩欧美综合在线二区三区 | 久久无码精品一区二区三区 | 欧美激情在线观看一区二区三区 | 日干夜操 | 亚洲精品视频在线观看免费 | 99re这里只有精品在线 | 四虎国产永久免费久久 | 热久久免费视频 | 国产亚洲精品久久综合影院 | 成人欧美一区二区三区黑人 | 成人18免费网 | 波多野结衣久久 | 中文字幕天天躁夜夜狠狠综合 | 一级欧美在线的视频 | 亚洲欧美国产精品 | 日本高清中文字幕一区二区三区a | 老子午夜精品我不卡影院 | 一区二区免费在线观看 | 日本老熟妇激情毛片 | 国产精品视频公开费视频 | 中文字幕三级在线不卡 | 写真福利 第 页 在线视频 | 亚洲美色综合天天久久综合精品 |