SlideShare a Scribd company logo
1 of 18
Twitter API Integration PHP, MySQL, Apache & Me
API API & More API
Search API Methods  search trends trends/current trends/daily trends/weekly   REST API Methods   Timeline Methods statuses/public_timeline  statuses/home_timeline statuses/friends_timeline statuses/user_timeline  statuses/mentions statuses/retweeted_by_me statuses/retweeted_to_me statuses/retweets_of_me  Status Methods statuses/show statuses/update statuses/destroy   statuses/retweet statuses/retweets statuses/id/retweeted_by  statuses/id/retweeted_by/ids  User Methods users/show  users/lookup users/search users/suggestions users/suggestions/category statuses/friends statuses/followers  List Methods          POST lists      (create)          POST lists id  (update)          GET lists        (index)          GET list id      (show)          DELETE list id (destroy)          GET list statuses          GET list memberships          GET list subscriptions  List Members Methods          GET list members          POST list members          DELETE list members          GET list members id  List Subscribers Methods          GET list subscribers          POST list subscribers          DELETE list subscribers          GET list subscribers id  Direct Message Methods  direct_messages direct_messages/sent direct_messages/new direct_messages/destroy  API API & More API
Spam Reporting Methods   report_spam  Saved Searches Methods saved_searches saved_searches/show saved_searches/create saved_searches/destroy OAuth Methods oauth/request_token oauth/authorize oauth/authenticate oauth/access_token   Geo methods geo/nearby_places   geo/reverse_geocode   geo/id   Friendship Methods friendships/create friendships/destroy  friendships/exists friendships/show friendships/incoming friendships/outgoing     Account Methods account/verify_credentials  account/rate_limit_status account/end_session account/update_delivery_device  account/update_profile_colors  account/update_profile_image  account/update_profile_background_image account/update_profile   Favorite Methods favorites favorites/create   favorites/destroy   Notification Methods notifications/follow  notifications/leave   Block Methods blocks/create   blocks/destroy blocks/exists blocks/blocking blocks/blocking/ids Social Graph Methods friends/ids    followers/ids    API API & More API
Latest Trends on Twitter as We Speak function getlatest(){	$url = 'http://search.twitter.com/trends/current.json?exclude=hashtags';	// create a new cURL resource	$ch = curl_init();// set URL and other appropriate optionscurl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // grab URL and pass it to the browser$json=curl_exec($ch);curl_close($ch);$obj_t=json_decode($json,true);echo “Latest Trends Today on Twitter.com @" .date('l jS f F Y h:i:s A‘)" ;}
Display Function (Array) function display($i_array) { foreach ($i_array as $i => $val) 	{ 	// check if element is array and trends only	 	if (is_array($val)){ 	 display($val);} 		else 		{ 		if($i=='name')	{ 		echo "<a href='http://twitter.com/search?q=$val'>$val</a><br>"; 			} 		  } 	} // end for }
Display Friends function display_following($screen_name) { if (!($screen_name=="")) { $url = 'http://api.twitter.com/1/statuses/friends.xml?screen_name='.$screen_name ; $xml = simplexml_load_file($url) or exit ("Unable to load XML!");  echo "<div id='result'>"; echo "<b>You Follow " .count($xml->user) ." Users</b><br>"; echo "<table>"; echo "<tr>"; $count = 0; foreach ($xml as $user => $u)  {  if ($count==3) {echo "</tr>"; $count=0;}   echo "<td><a href='http://twitter.com/$u->screen_name'>"   ."<img height='50' width='50' title=".$u->screen_name ." src='" .$u->profile_image_url ."'/>" ."</a></td>";       $count = $count + 1; }  echo "</tr></table>"; echo "</div>"; } else {} }//end display_following()
DisplayFollowers function display_followers($screen_name) { 	if (!($screen_name=="")) 	{ 		$curl_conn = curl_init(); 		$url = 'http://twitter.com/statuses/followers/' .$screen_name .'.xml'; 		$xml = simplexml_load_file($url) or exit ("Unable to load XML!");  		echo "<div id='result'>"; 		echo "<b>Your " .count($xml->user) ." Followers</b><br>"; 		echo "<table>"; 		echo "<tr>"; 		$count = 0; foreach ($xml as $user => $u)  		{  		if ($count==3) 		{echo "</tr>“;	$count=0;} 		  echo "<td><a href='http://twitter.com/$u->screen_name'>" 	 ."<img height='50' width='50' title=".$u->screen_name ." src='".$u->profile_image_url ."'/>"  	."</a></td>";     		 $count = $count + 1; 		} //end for 		echo "</tr></table>"; 		echo "</div>"; 	}  	else 	{ 	//display_form(); 	} }//end display_followers()
Add Tweet function post($username,$password,$tweet) { $status = urlencode(stripslashes(urldecode($_POST['tweet']))); if ($status) { $tweetUrl = 'http://www.twitter.com/statuses/update.xml'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "$tweetUrl"); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status"); curl_setopt($curl, CURLOPT_USERPWD, "$username:$password"); $result = curl_exec($curl); $resultArray = curl_getinfo($curl); 	if ($resultArray['http_code'] == 200) 	{ 		//echo 'Tweet Posted'; 		display(); 	} 	else 	{ 		echo 'Could not post Tweet to Twitter right now. Try again later.'; display_form(); 	} curl_close($curl); 	} // end status }//end post
Linkify function linkify($text)       {   $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_.~#?&//=]+)‘,         '<a href="1">1</a>', $text);   text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_.~#?&//=]+)‘, '1<a href="http://2">2</a>', $text);   $text = eregi_replace('([_0-9a-z-]+@([0-9a-z][0-9a-z-]+)+[a-z]{2,3})‘,      '<a href="mailto:1">1</a>', $text);   return $text;       }
Like Shorter URLS function make_bitly_url($url,$login,$appkey,$format = 'xml',$version = '2.0.1') { 	//create the URL 	$bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format; 	//get the url 	//could also use cURL here 	$response = file_get_contents($bitly); 	//parse depending on desired format 	if(strtolower($format) == 'json') 	{ 		$json = @json_decode($response,true); 		return $json['results'][$url]['shortUrl']; 	} 	else //xml 	{ 		$xml = simplexml_load_string($response); 		return 'http://bit.ly/'.$xml->results->nodeKeyVal->hash; 	} } /* usage */ $short = make_bitly_url($_GET['url'],'davidwalshblog','R_9acc320c5c423e4f5192e00ff24980','json'); //echo 'The short URL for "http://www.devitsolutions.com" is:  <a style="color:Green" href='.$short .'>Link</a>';  echo $short;
Last status function get_status($twitter_id, $hyperlinks = true) {     $c = curl_init(); curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1"); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);     $src = curl_exec($c); curl_close($c); preg_match('/<text>(.*)<text>/', $src, $m);     $status = htmlentities($m[1]);     if( $hyperlinks )  $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=quot;0quot;>0</a>", $status);     return($status); }
LIVE DEMO WWW.iwilltypeurl.com
THANKS TWITTER , IBM AND HOW CAN I FORGET U ALL
CATCH ME ON TWITTER @utpalbetai

More Related Content

What's hot

Google search techniques
Google search techniquesGoogle search techniques
Google search techniquesOusman Faal
 
Webinar: Online Fundraising
Webinar: Online FundraisingWebinar: Online Fundraising
Webinar: Online FundraisingifPeople
 
Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011Juan Sequeda
 
funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會Nathan Chiu
 

What's hot (9)

Google search techniques
Google search techniquesGoogle search techniques
Google search techniques
 
Webinar: Online Fundraising
Webinar: Online FundraisingWebinar: Online Fundraising
Webinar: Online Fundraising
 
Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011Creating Linked Data 2/5 Semtech2011
Creating Linked Data 2/5 Semtech2011
 
Oo Perl
Oo PerlOo Perl
Oo Perl
 
Seoptimizing
SeoptimizingSeoptimizing
Seoptimizing
 
Ruby on discuz
Ruby on discuzRuby on discuz
Ruby on discuz
 
mmiuc
mmiucmmiuc
mmiuc
 
funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會funP 麻吉 開發者俱樂部十月份聚會
funP 麻吉 開發者俱樂部十月份聚會
 
google dork.pdf
google dork.pdfgoogle dork.pdf
google dork.pdf
 

Similar to Twitter (20)

Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 
Forum Presentation
Forum PresentationForum Presentation
Forum Presentation
 
JQuery 101
JQuery 101JQuery 101
JQuery 101
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In Php
 
Php 3 1
Php 3 1Php 3 1
Php 3 1
 
State Machines to State of the Art
State Machines to State of the ArtState Machines to State of the Art
State Machines to State of the Art
 
Architecting Web Services
Architecting Web ServicesArchitecting Web Services
Architecting Web Services
 
External Data Access with jQuery
External Data Access with jQueryExternal Data Access with jQuery
External Data Access with jQuery
 
The Basics Of Page Creation
The Basics Of Page CreationThe Basics Of Page Creation
The Basics Of Page Creation
 
Open Hack 2008 Mybloglog
Open Hack 2008 MybloglogOpen Hack 2008 Mybloglog
Open Hack 2008 Mybloglog
 
Web Scraping with PHP
Web Scraping with PHPWeb Scraping with PHP
Web Scraping with PHP
 
Evolution of API With Blogging
Evolution of API With BloggingEvolution of API With Blogging
Evolution of API With Blogging
 
Component and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHPComponent and Event-Driven Architectures in PHP
Component and Event-Driven Architectures in PHP
 
PHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodPHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the Good
 
Zend Form Tutorial
Zend Form TutorialZend Form Tutorial
Zend Form Tutorial
 
Mojolicious on Steroids
Mojolicious on SteroidsMojolicious on Steroids
Mojolicious on Steroids
 
Meetup django common_problems(1)
Meetup django common_problems(1)Meetup django common_problems(1)
Meetup django common_problems(1)
 
Php Basic Security
Php Basic SecurityPhp Basic Security
Php Basic Security
 
Further Php
Further PhpFurther Php
Further Php
 
Haml & Sass presentation
Haml & Sass presentationHaml & Sass presentation
Haml & Sass presentation
 

More from Utpal Betai

Decentralised Financing (DeFi)
Decentralised Financing (DeFi)Decentralised Financing (DeFi)
Decentralised Financing (DeFi)Utpal Betai
 
Gdg dev fest 2019
Gdg dev fest 2019Gdg dev fest 2019
Gdg dev fest 2019Utpal Betai
 
Keynote focus on future
Keynote focus on future Keynote focus on future
Keynote focus on future Utpal Betai
 
Keynote Android
Keynote Android Keynote Android
Keynote Android Utpal Betai
 
Top 10 app developer excuses
Top 10 app developer excusesTop 10 app developer excuses
Top 10 app developer excusesUtpal Betai
 
Apple design awards 2014
Apple design awards 2014Apple design awards 2014
Apple design awards 2014Utpal Betai
 
I os8 in 8 slides
I os8 in 8 slidesI os8 in 8 slides
I os8 in 8 slidesUtpal Betai
 
Mobile app for Business Success
Mobile app for Business SuccessMobile app for Business Success
Mobile app for Business SuccessUtpal Betai
 
Google Glass Development Kit - Developer Zone
Google Glass Development Kit - Developer ZoneGoogle Glass Development Kit - Developer Zone
Google Glass Development Kit - Developer ZoneUtpal Betai
 
Google mirror api
Google mirror apiGoogle mirror api
Google mirror apiUtpal Betai
 
App monetization
App monetizationApp monetization
App monetizationUtpal Betai
 

More from Utpal Betai (16)

Decentralised Financing (DeFi)
Decentralised Financing (DeFi)Decentralised Financing (DeFi)
Decentralised Financing (DeFi)
 
Gdg dev fest 2019
Gdg dev fest 2019Gdg dev fest 2019
Gdg dev fest 2019
 
Keynote focus on future
Keynote focus on future Keynote focus on future
Keynote focus on future
 
Keynote 2017
Keynote   2017 Keynote   2017
Keynote 2017
 
Keynote Android
Keynote Android Keynote Android
Keynote Android
 
Top 10 app developer excuses
Top 10 app developer excusesTop 10 app developer excuses
Top 10 app developer excuses
 
Apple design awards 2014
Apple design awards 2014Apple design awards 2014
Apple design awards 2014
 
Appmonetization
AppmonetizationAppmonetization
Appmonetization
 
I os8 in 8 slides
I os8 in 8 slidesI os8 in 8 slides
I os8 in 8 slides
 
Eye opener
Eye openerEye opener
Eye opener
 
Mobile app for Business Success
Mobile app for Business SuccessMobile app for Business Success
Mobile app for Business Success
 
Google Glass Development Kit - Developer Zone
Google Glass Development Kit - Developer ZoneGoogle Glass Development Kit - Developer Zone
Google Glass Development Kit - Developer Zone
 
Google mirror api
Google mirror apiGoogle mirror api
Google mirror api
 
Androit kitkat
Androit kitkatAndroit kitkat
Androit kitkat
 
App monetization
App monetizationApp monetization
App monetization
 
Led money
Led moneyLed money
Led money
 

Recently uploaded

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Twitter

  • 1. Twitter API Integration PHP, MySQL, Apache & Me
  • 2.
  • 3.
  • 4.
  • 5. API API & More API
  • 6. Search API Methods  search trends trends/current trends/daily trends/weekly   REST API Methods   Timeline Methods statuses/public_timeline  statuses/home_timeline statuses/friends_timeline statuses/user_timeline  statuses/mentions statuses/retweeted_by_me statuses/retweeted_to_me statuses/retweets_of_me  Status Methods statuses/show statuses/update statuses/destroy   statuses/retweet statuses/retweets statuses/id/retweeted_by  statuses/id/retweeted_by/ids  User Methods users/show  users/lookup users/search users/suggestions users/suggestions/category statuses/friends statuses/followers  List Methods          POST lists      (create)          POST lists id  (update)          GET lists        (index)          GET list id      (show)          DELETE list id (destroy)          GET list statuses          GET list memberships          GET list subscriptions  List Members Methods          GET list members          POST list members          DELETE list members          GET list members id  List Subscribers Methods          GET list subscribers          POST list subscribers          DELETE list subscribers          GET list subscribers id  Direct Message Methods  direct_messages direct_messages/sent direct_messages/new direct_messages/destroy  API API & More API
  • 7. Spam Reporting Methods   report_spam  Saved Searches Methods saved_searches saved_searches/show saved_searches/create saved_searches/destroy OAuth Methods oauth/request_token oauth/authorize oauth/authenticate oauth/access_token   Geo methods geo/nearby_places   geo/reverse_geocode   geo/id   Friendship Methods friendships/create friendships/destroy  friendships/exists friendships/show friendships/incoming friendships/outgoing     Account Methods account/verify_credentials  account/rate_limit_status account/end_session account/update_delivery_device  account/update_profile_colors  account/update_profile_image  account/update_profile_background_image account/update_profile   Favorite Methods favorites favorites/create   favorites/destroy   Notification Methods notifications/follow  notifications/leave   Block Methods blocks/create   blocks/destroy blocks/exists blocks/blocking blocks/blocking/ids Social Graph Methods friends/ids    followers/ids    API API & More API
  • 8. Latest Trends on Twitter as We Speak function getlatest(){ $url = 'http://search.twitter.com/trends/current.json?exclude=hashtags'; // create a new cURL resource $ch = curl_init();// set URL and other appropriate optionscurl_setopt($ch, CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_HEADER, 0);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // grab URL and pass it to the browser$json=curl_exec($ch);curl_close($ch);$obj_t=json_decode($json,true);echo “Latest Trends Today on Twitter.com @" .date('l jS f F Y h:i:s A‘)" ;}
  • 9. Display Function (Array) function display($i_array) { foreach ($i_array as $i => $val) { // check if element is array and trends only if (is_array($val)){ display($val);} else { if($i=='name') { echo "<a href='http://twitter.com/search?q=$val'>$val</a><br>"; } } } // end for }
  • 10. Display Friends function display_following($screen_name) { if (!($screen_name=="")) { $url = 'http://api.twitter.com/1/statuses/friends.xml?screen_name='.$screen_name ; $xml = simplexml_load_file($url) or exit ("Unable to load XML!"); echo "<div id='result'>"; echo "<b>You Follow " .count($xml->user) ." Users</b><br>"; echo "<table>"; echo "<tr>"; $count = 0; foreach ($xml as $user => $u) { if ($count==3) {echo "</tr>"; $count=0;} echo "<td><a href='http://twitter.com/$u->screen_name'>" ."<img height='50' width='50' title=".$u->screen_name ." src='" .$u->profile_image_url ."'/>" ."</a></td>"; $count = $count + 1; } echo "</tr></table>"; echo "</div>"; } else {} }//end display_following()
  • 11. DisplayFollowers function display_followers($screen_name) { if (!($screen_name=="")) { $curl_conn = curl_init(); $url = 'http://twitter.com/statuses/followers/' .$screen_name .'.xml'; $xml = simplexml_load_file($url) or exit ("Unable to load XML!"); echo "<div id='result'>"; echo "<b>Your " .count($xml->user) ." Followers</b><br>"; echo "<table>"; echo "<tr>"; $count = 0; foreach ($xml as $user => $u) { if ($count==3) {echo "</tr>“; $count=0;} echo "<td><a href='http://twitter.com/$u->screen_name'>" ."<img height='50' width='50' title=".$u->screen_name ." src='".$u->profile_image_url ."'/>" ."</a></td>"; $count = $count + 1; } //end for echo "</tr></table>"; echo "</div>"; } else { //display_form(); } }//end display_followers()
  • 12. Add Tweet function post($username,$password,$tweet) { $status = urlencode(stripslashes(urldecode($_POST['tweet']))); if ($status) { $tweetUrl = 'http://www.twitter.com/statuses/update.xml'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, "$tweetUrl"); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status"); curl_setopt($curl, CURLOPT_USERPWD, "$username:$password"); $result = curl_exec($curl); $resultArray = curl_getinfo($curl); if ($resultArray['http_code'] == 200) { //echo 'Tweet Posted'; display(); } else { echo 'Could not post Tweet to Twitter right now. Try again later.'; display_form(); } curl_close($curl); } // end status }//end post
  • 13. Linkify function linkify($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_.~#?&//=]+)‘, '<a href="1">1</a>', $text); text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_.~#?&//=]+)‘, '1<a href="http://2">2</a>', $text); $text = eregi_replace('([_0-9a-z-]+@([0-9a-z][0-9a-z-]+)+[a-z]{2,3})‘, '<a href="mailto:1">1</a>', $text); return $text; }
  • 14. Like Shorter URLS function make_bitly_url($url,$login,$appkey,$format = 'xml',$version = '2.0.1') { //create the URL $bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$login.'&apiKey='.$appkey.'&format='.$format; //get the url //could also use cURL here $response = file_get_contents($bitly); //parse depending on desired format if(strtolower($format) == 'json') { $json = @json_decode($response,true); return $json['results'][$url]['shortUrl']; } else //xml { $xml = simplexml_load_string($response); return 'http://bit.ly/'.$xml->results->nodeKeyVal->hash; } } /* usage */ $short = make_bitly_url($_GET['url'],'davidwalshblog','R_9acc320c5c423e4f5192e00ff24980','json'); //echo 'The short URL for "http://www.devitsolutions.com" is: <a style="color:Green" href='.$short .'>Link</a>'; echo $short;
  • 15. Last status function get_status($twitter_id, $hyperlinks = true) { $c = curl_init(); curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1"); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); $src = curl_exec($c); curl_close($c); preg_match('/<text>(.*)<text>/', $src, $m); $status = htmlentities($m[1]); if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]", "<a href=quot;0quot;>0</a>", $status); return($status); }
  • 17. THANKS TWITTER , IBM AND HOW CAN I FORGET U ALL
  • 18. CATCH ME ON TWITTER @utpalbetai