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

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
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
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
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
 

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