
set serverout on size unlimited;
exec dbms_java.set_output(2000000);
set define off


-- Post a message on Twitter
select JDBMS_TWITTER.SET_STATUS (
iLOGIN => 'rastadidi',
iPASSWORD => 'YOUR_PASSWORD',
iSTATUS_TEXT => 'oracle-jutils is now able to Twitt with JDBMS_TWITTER. Interaction between Oracle and Twitter is now easy. Give it a try.')
from dual;

select JDBMS_TWITTER.PING_TWITTER (
iLOGIN => 'rastadidi',
iPASSWORD => 'YOUR_PASSWORD') as PING_TWITTER_STATUS
from dual;

-- Test with a custom twitter url (here the standard one)
select JDBMS_TWITTER.PING_TWITTER (
iROOT_URL => 'http://twitter.com',
iLOGIN => 'rastadidi',
iPASSWORD => 'YOUR_PASSWORD') as PING_TWITTER_STATUS
from dual;

select JDBMS_TWITTER.SET_STATUS (
iLOGIN => 'rastadidi',
iPASSWORD => 'YOUR_PASSWORD',
iSTATUS_TEXT => 'New function to get status')
from dual;

-- Get the status of some twitters :
select * from table(TWITTER_STATUS(NULL, 'rastadidi', 'YOUR_PASSWORD', 'dcmomo'))
union all
select * from table(TWITTER_STATUS(NULL, 'rastadidi', 'YOUR_PASSWORD', 'Guggenheim'));

-- Get friends informations for a ojutils account
select * from table(TWITTER_FRIENDS(iRootUrl => NULL, iLogin => 'ojutils', iPassword => 'YOUR_PASSWORD'));

select creation_date as "Created",
Description as "Desc",
Location as "Location",
Name as "Name",
screen_name "Scr.",
followers_count "Followers",
TIMEZONE_OFFSET/60/60 "TMZ Hrs."
from table(TWITTER_FRIENDS(iRootUrl => NULL, iLogin => 'ojutils', iPassword => 'YOUR_PASSWORD'))
order by "Followers" desc;

-- Make stats onb your Friends
select location , count(*) Friends
from table(TWITTER_FRIENDS(iRootUrl => NULL, iLogin => 'ojutils', iPassword => 'YOUR_PASSWORD'))
where location is not null
group by location
order by count(*) desc;


select * from table(TWITTER_FAVORITES(iRootUrl => NULL, iLogin => 'ojutils', iPassword => 'YOUR_PASSWORD', iUserName => 'ojutils'));

select T.CREATED_AT "Created at",
		T.TEXT "Text",
		T.MENTIONS "Mentions",
		T.USER_NAME "Name",
		T.USER_SCREEN_NAME "Scr. Name",
		T.USER_WEBSITE "Website"
from table(TWITTER_FAVORITES(iRootUrl => NULL,
	iLogin => 'YOUR_LOGIN',
	iPassword => 'YOUR_PASSWORD',
	iUserName => 'ninjatunehq')) T;
	

-- Retrieve the messages you have sent
select Created_at "Date", text "Sent Messages",
    recipient_screen_name "Recipient", sender_screen_name "Sender"
from table(TWITTER_DIRECT_MESSAGES(iRootUrl => NULL, iLogin => 'ojutils', iPassword => 'THE_PASSWORD', iSentFlag => 1));

-- Retrieve the messages you have in your inbox
select Created_at "Date", text "Inbox Messages",
    recipient_screen_name "Recipient", sender_screen_name "Sender"
from table(TWITTER_DIRECT_MESSAGES(iRootUrl => NULL, iLogin => 'ojutils', iPassword => 'THE_PASSWORD', iSentFlag => 0));

set serverout on size unlimited;
exec dbms_java.set_output(2000000);
set define off

select * from table(TWITTER_FOLLOWERS(iRootUrl => NULL, iLogin => 'ojutils', iPassword => 'YOUR_PASSWORD', iUserName => NULL));

-- Get some info about the followers of a given twitter account (here rastadidi)
select created_at "Creat. Date",
    followers_count "Nb. Followers",
    id "Id",
    name "Name",
    screen_name "Scr. Name",
    status_text "Current Status"
from table(TWITTER_FOLLOWERS(iRootUrl => NULL, iLogin => 'ojutils', iPassword => 'YOUR_PASSWORD', iUserName => 'rastadidi'));

-- Get some info about your followers
select created_at "Creat. Date",
    followers_count "Nb. Followers",
    id "Id",
    name "Name",
    screen_name "Scr. Name",
    status_text "Current Status"
from table(TWITTER_FOLLOWERS(iRootUrl => NULL, iLogin => 'YOUR_LOGIN', iPassword => 'YOUR_PASSWORD', iUserName => NULL));
	
	
select * from table(TWITTER_REPLIES(iRootUrl => NULL, iLogin => 'YOUR_LOGIN', iPassword => 'YOUR_PASSWORD'));


-- Get Friends Timelines
select * from table(TWITTER_TIMELINE(iRootUrl => NULL, iLogin => 'YOUR_LOGIN', iPassword => 'YOUR_PASSWORD', iFriendsFlag => 1));

-- Get Home Timelines
select * from table(TWITTER_TIMELINE(iRootUrl => NULL, iLogin => 'YOUR_LOGIN', iPassword => 'YOUR_PASSWORD', iFriendsFlag => 0));

-- Send a Message
select JDBMS_TWITTER.SEND_MESSAGE (iLOGIN => 'YOUR_LOGIN',
	iPASSWORD => 'YOUR_PASSWORD',
	iRECIPIENT => 'ojutils',
	iTEXT => 'Hello, oracle-jutils is now able to send direct messages thanks to JDBMS_TWITTER.SEND_MESSAGE') as MSG_ID
from dual;

-- Test wether a user exists
select JDBMS_TWITTER.USER_EXISTS (iLOGIN => 'YOUR_LOGIN',
	iPASSWORD => 'YOUR_PASSWORD',
	iSCREEN_NAME => 'theScreenNameYouWantToTest') as USER_EXISTS
from dual;


