YesYo.com MintState Forums  
뒤로    YesYo.com MintState BBS > Tech > Ajax & Issue
검색
멤버이름  오토
비밀번호 
 

 
작성일 : 11-06-01 15:34
PHP Twitter Search API
 글쓴이 : MintState
조회 : 5,288  
PHP Twitter Search API

I've implemented the twitter search API in a PHP class just for fun. It implements the entire search API as of February 25, 2009. I've only tested this with PHP 5.2.6 but I am fairly confident that most installations of PHP5 should work just fine. If you try it with PHP4 and it works (or if you have to jigger it) let me know.

You can get the source code at http://greenservr.com/projects/twittersearch/TwitterSearch.phps

Here are a couple examples (after including the class):

This example makes use of method chaining to create a "sentence". Chaining isn't a requirement but I think it works here. What this example does is search for tweets from the user "ryanfaerman" with the hashtag "#flsccc".

$search = new TwitterSearch();
$search->user_agent = 'phptwittersearch:ryan.faerman@gmail.com';

$results = $search->from('ryanfaerman')->with('flsccc')->results();
The user agent is optional, but is recommended. This way the folks over at Twitter know who is hitting their server. I'll be leaving it out in other examples for clarity.

If you want to put in the query during instantiation, you can do that too. Anything that you'd use on search.twitter.com can be passed as the argument. This example searches all twitter for any tweets that mention the word "monkey".

$search = new TwitterSearch('monkey');
$results = $search->results();
Each time you add another search term, it is appended to the query you are building. Once you get the results, the query is cleared.

This example searches for the last 50 tweets from the user ?darthvader? where he mentions ?storm trooper?.

$search->from('darthvader');
$search->contains('storm trooper');
$results = $search->rpp(50)->results();
This example searches for any tweets within a 25 mile radius of the provided coordinates.

$results = $search->geocode(40.757929, -73.985506, 25)->results();
There are quite a few more search operators which are clear from the source code, so I encourage you to take a look. Lastly, there is the trends function. Calling this method returns the top ten queries that are currently trending on Twitter.

$trends = $search->trends();
If you end up using this in a project of yours, I'd really enjoy hearing about it.


URL : http://ryanfaerman.com/twittersearch/
첨부 파일
파일 종류: php TwitterSearch.php (10.2K, 1 views)
Rated 0/5 (0%) (0 Votes)

(\__/)
(='.'=)
(")_(")~
Search Infomation by MintState
MintState

 
 

Total 32
번호 제   목 글쓴이 날짜 조회
32 Swiper - Most Modern Mobile Touch Slider MintState 02-02 1513
31 [jquery] 스와프 가능한 이미지 배너 - OWL Carousel MintState 05-30 2836
30 구글맵 api 편리하기 사용가능하게 해주는 gmaps.js MintState 03-04 4322
29 jQuery - FullCalendar MintState 03-21 5915
28 jquery - select box MintState 11-25 5883
27 Wowza Streaming Server MintState 09-19 7650
26 jQuery Datepicker MintState 06-23 6766
25 Using the Twitter Search API MintState 06-01 4729
24 Twitter Search using the Twitter API and PHP MintState 06-01 5404
23 PHP Twitter Search API MintState 06-01 5289
22 모바일(iOS 용) 터치 관련 jQuery 플러그인 MintState 04-18 6332
21 GEO <-> KATEC 변환 MintState 02-21 5514
20 Twitter API 링크 MintState 07-13 7758
19 jQuery Simple WYSIWYG Editor MintState 07-02 8230
18 Prototype.js 의 Object 객체의 메소드 MintState 01-19 6539
17 prototype.js 를 이용한 JSON사용 예제 MintState 01-19 10459
16 php 내장함수을 이용한 XML Parser MintState 08-27 8451
15 XML 파싱(xml2array) MintState 08-27 8093
14 ajax의 xml을 javascript 객체형식으로 자동 변환 MintState 07-07 8364
13 Google Maps API (1) MintState 03-18 14088
 1  2  
모바일 버전으로 보기
CopyRight ©2004 - 2017, YesYo.com MintState. ™