MintState Forums  
뒤로 MintState BBS > Tech > Ajax & Issue
멤버이름  오토

작성일 : 11-06-01 15:34
PHP Twitter Search API
 글쓴이 : MintState
조회 : 5,650  
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

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 = '';

$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 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->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.

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

Search Infomation by MintState


Total 32
번호 제   목 글쓴이 날짜 조회
32 Swiper - Most Modern Mobile Touch Slider MintState 02-02 1927
31 [jquery] 스와프 가능한 이미지 배너 - OWL Carousel MintState 05-30 3270
30 구글맵 api 편리하기 사용가능하게 해주는 gmaps.js MintState 03-04 4710
29 jQuery - FullCalendar MintState 03-21 6288
28 jquery - select box MintState 11-25 6271
27 Wowza Streaming Server MintState 09-19 8343
26 jQuery Datepicker MintState 06-23 7203
25 Using the Twitter Search API MintState 06-01 5079
24 Twitter Search using the Twitter API and PHP MintState 06-01 6234
23 PHP Twitter Search API MintState 06-01 5651
22 모바일(iOS 용) 터치 관련 jQuery 플러그인 MintState 04-18 6759
21 GEO <-> KATEC 변환 MintState 02-21 5920
20 Twitter API 링크 MintState 07-13 8112
19 jQuery Simple WYSIWYG Editor MintState 07-02 8727
18 Prototype.js 의 Object 객체의 메소드 MintState 01-19 6891
17 prototype.js 를 이용한 JSON사용 예제 MintState 01-19 10815
16 php 내장함수을 이용한 XML Parser MintState 08-27 8841
15 XML 파싱(xml2array) MintState 08-27 8564
14 ajax의 xml을 javascript 객체형식으로 자동 변환 MintState 07-07 8753
13 Google Maps API (1) MintState 03-18 14565
 1  2  
모바일 버전으로 보기
CopyRight ©2004 - 2018, MintState. ™