Using the Twitter API - php

I am trying to build a small useful application with twitter. I will publish it as an open source project once I am done. I am trying to decide what is the best way to do the following:
I want to get the latest 200 tweets from Washington for example and see the most important thing these 200 tweets share. For example, if 20 tweets have tweeted the same link, this is probably an important story in Washington. Or if 50 tweets mentioned (This specific subject) it means this is important and I could get information about it.
What is the best way to do that? and is there a better way to get this information without getting the latest 200 tweets (except trends).
If you feel like this is not clear enough please provide some questions and I will clear this up
Thank you all for the help.

I don't think there is going to be any "custom" trending available, so you are going to have to parse out the links from the search results yourself.
You would use the search api function:
http://search.twitter.com/search.atom?geocode=40.757929%2C-73.985506%2C25km
After that, it should be pretty trivial to maintain a list of trends and links over the past 24 hours.

I would suggest you use a php twitter library which does already the things you wrote.
Please have a look at this question to find a library which fits your needs https://stackoverflow.com/questions/422879/best-twitter-php-library

Related

Extract data from forum

İ want to extract data from a php forum based on keywords I entered.
İs there something ready that can do this?
Just to give example
Kadinlarkulubu.com/forum.php
Keywords ios, android
Thanks to this info I want to get date, time, message, URL of message, keyword in the message, nick of member who wrote this message.
I need to work in different forums, so I need one or more tools that will work on key big platforms like vBulletin.
You need to create your own web crawler. If you want it to work on various different platforms, you will have to create variations on that crawler.
To start, picks your favourite forum, and give it a seed page (the page where to start crawling). Tread carefully, since you may need to be logged in to be able to see posts, and if that's the case, it may not be easy to do (making a crawler that logs you in, and breaks the captcha, for example). You can also make use of the search functionality (since many forums have search URLs similar to ?q=your_tag&p=1, this could make things a lot easier.
Just check that you're on the same domain, and that you don't go into an infinite loop, other than that, you should be fine.
Expect this to be a long term project :)
The alternative would be using API, if the forum provides one, but I doubt you will be so lucky.
2 ways
The easy way is only possible if the owner of the forum provides you access to the forum API (if it has one) or the database
The extreme hard way is make a grabber that reads a forum page by page and parses the information you like to something you can use.

How do I show "daily hits" in any URL (visits/page loads)?

I need to count page views (from any url on my site including search pages) and show them on my site but I can't manage to make it work. I wanted to show the numer of times a page is loaded daily but at this point I don't really care whether I get pageviews, single visitors, or any kind of visits, as long as I do have some kind of counter.
Is there an easy way to do it?
Thanks
Yeah. The easiest way is to use Google Analytics.
I would suggest one of the free web statistics programs out there to just analyze your web logs. They'll be more fully featured than just counting visits, and there will be no overhead of database transactions just because someone is visiting a page.
http://awstats.sourceforge.net/
First, I'd have to say it: displaying number of views is SO 2000.
Well, now to the actual question, you'll have to identify each page and find out how flexible that can be:
/?p=1
/?p=1&q=2
/?p=1&s=1
Those might be the paths and might be referring to the same object, so you'll have to grab it and parse it if necessary. Now, just save it to a table in your database and increase the counter each time a new view is there.
Back on Visonary Software Solutions' track. I would use a Google Analytics-based solution too, perhaps you will use it on your site anyway. I did a quick search and found a tutorial on how to create counters like you wanted, displaying Analytics data. It doesn't look so complicated.
http://www.webresourcesdepot.com/feedcount-like-google-analytics-counter/
As far as I can tell, there are quite a lot of extensions for this purpose for the popular CMSs:
For Drupal: http://drupal.org/project/google_analytics_counter
For WordPress: http://analytics.blogspot.com/2009/05/share-your-google-analytics-data-with.html

Simple way for read only twitter api usage

probably like many people my site has been affected by twitter deprecating basic authentication, so I was looking at implementing OAuth. But all I want to do is just pull the last couple of tweets from my account - I don't need to post anything, it's just readonly access to the user timeline. I've seen a couple of posts showing how to do this easily with javascript, so i'm thinking it might also be similarly straightforward with PHP (i.e not requiring OAuth)? One reason for having to use PHP instead of Javascript is that i need to check when the rate limit is about to be exceeded, then I cache the last couple of tweets for the required amount of time.
If OAuth is the best solution, I'll get on with that - grateful for any suggestions though!
I wrote a article showing how to do this:
http://philsturgeon.co.uk/news/2009/07/How-to-Create-a-Twitter-feed-with-full-syntax-support
but the basics are even easier. It all boils down to:
$tweets = json_decode(
file_get_contents('http://twitter.com/statuses/user_timeline/philsturgeon.json?count=10')
);
Enjoy.

Is there any simple way of interfacing with Twitter/OAuth using PHP?

I am losing my mind here.
Im looking at a beginners OAuth php package that has a 700 line file. Im used to using 10-12 lines of CURL or just a couple lines with simpleXML to get the same data. Is there a very meat and potatoes way to convey the concepts of interfacing with twitter via oauth without totally alienating someone?
Im used to learning by downloading an example, and tooling around with it. The only examples i can find are so confusing that id have to take a course to begin to understand the DEMO.
Specific Question:
I have a users access token. The api address is
http://twitter.com/statuses/friends_timeline.xml
How do i take the token, and mash it into the address and make that give me the data that i want? Im willing to learn, but i cant learn if i dont understand what is going on to begin with. I get the basics, you send a request, user approves, you get a token, i get that. I dont get how you make the requests with your token as authorization in place of the plain text user and pass.
Have you considered looking at one of the Twitter API PHP libraries listed on the Twitter API wiki?
I felt exactly the same, but then I found EpiTwitter which makes the whole process much, much easier. Checkout the authors blog for specific examples that actually work :)
I haven't tried this library, but someone posted a link to simple OAuth library few day ago here.

Scraping from wsj.com or finance.yahoo.com

I want to display on a wordpress page the total volume of shares traded on the NYSE stock exchange the last 2 weeks that it's been open. What is the best way to go about doing this?
Yahoo Finance lets you export their data.
For a ticker, on the left sidebar there is a link to Historical Prices. On the bottom of that page there is a link "Download To Spreadsheet".
You could pass that to fgetcsv to parse it.
Scraping websites for data is generally seen as unethical, depending on your intentions and the frequency of the scrape. The bandwidth isn't free, you know. Instead, you should hopefully be able to find a data feed which has been designed to be consumed by other sites, such as yours.
Not knowing very much about your domain, I wouldn't really know what to search for, but here's some guesses:
The NYSE website seems to offer a subscription data feed
Look around the Yahoo Finance page here
Yahoo would be your best bet as they have an unofficial api documented here:
http://www.gummy-stuff.org/Yahoo-data.htm
Tons of apps/widgets rely on this so I can't see it going away
It has in fact gone away, due to yahoo asking that it be taken down.
From first glance, this url would give you what you need: http://finance.yahoo.com/d/quotes.csv?s=^NYA&f=v

Categories