forked from remi/pubwich
-
Notifications
You must be signed in to change notification settings - Fork 27
ServiceTwitter
haschek edited this page Sep 13, 2012
·
1 revision
This service integrates users status streams and a keyword searches from Twitter within your PubwichFork page.
Before you can use the Twitter service class you need to create a new Twitter application because the service class is using Twitter's OAuth authentification to request data. It's easy to create it:
- Go to https://dev.twitter.com/apps/ and create a new application
- Fill out the data:
- Name: My PubwichFork
- Description: My PubwichFork needs some data.
- Website: http://eye48.com/go/pubwichfork
- Callback URL: http://example.com/pubwichfork (use the URL where your PubwichFork installation is accessible)
- save it
- Request the Access Token at the bottom of the details page
Now you can copy the necessary keys, tokens and secrets to configure the Twitter service class.
-
method: either
TwitterUser
orTwitterSearch
-
oauth: an php array with values for following keys:
app_consumer_key
,app_consumer_secret
,user_access_token
anduser_access_token_secret
... and all basic options of services.
-
username: the users name on Twitter, taken from
https://twitter.com/username
- terms: keyword phrase you want search for
$twitter_pf = array(
'Twitter', 'twitter_pf', array(
'method' => 'TwitterSearch',
'terms' => 'PubwichFork',
'oauth' => array(
'app_consumer_key' => 'YOUR_APP_CONSUMER_KEY_STRING',
'app_consumer_secret' => 'YOUR_APP_CONSUMER_SECRET_STRING',
'user_access_token' => 'YOUR_USER_ACCESS_TOKEN_STRING',
'user_access_token_secret' => 'YOUR_USER_ACCESS_TOKEN_SECRET_STRING'
),
'total' => 5,
'title' => 'Twitter',
'description' => 'PubwichFork search'
)
);
- text: the original text withouth any links
- status: the text with link replacements for @username, #hashtag and URL strings
- date: date of the tweet
- link: permanent URL of the status tweet
- user_name: full name of the user who tweeted
-
user_nickname: short name of the user who tweeted, like in
https://twitter.com/shortname
- user_link: permanent URL of the user
- user_image: thumbnail image of the user
function TwitterSearch_itemTemplate() {
return '<li>
<a href="{{{user_link}}}"><img class="item-media-thumbnail" width="48" height="48" src="{{{user_image}}}" alt="" />
<strong>@{{{user_nickname}}}</strong></a>:
{{{status}}}
(<a href="{{{link}}}">{{{date}}}</a>)
</li>'.PHP_EOL;
}