Solved

Twitter api question/help needed

Posted on 2010-11-28
3
248 Views
Last Modified: 2012-05-10

I have the code below for tapping into the twitter api and getting trends.

Is there a way to adjust it to collect trends in the US only?

Thanks,   Chris


<?php
$contents = file_get_contents(
    "http://search.twitter.com/trends.json");
$json = json_decode($contents);
 
foreach ($json->trends as $trend) {
echo $trend->name.'<br>';
}
?>


0
Comment
Question by:St_Aug_Beach_Bum
  • 2
3 Comments
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 34228533
It does not appear to be readily available.  No identifying information is present in the JSON object.
<?php // RAY_temp_staug.php
$contents = file_get_contents("http://search.twitter.com/trends.json");
$json = json_decode($contents);

foreach ($json->trends as $trend)
{
    echo $trend->name.'<br>';
}

// EXPOSE THE OBJECT
echo "<pre>";
var_dump($json);

Open in new window

0
 

Author Closing Comment

by:St_Aug_Beach_Bum
ID: 34236186
Thank you Ray. I found a place on twitters site saying they would support location trends in the data feeds 'later', and that was several months ago. No dice yet I guess.

I'll try to tackle this from another direction :)

Thanks again,  Chris
0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 34238283
Thanks for the points.  Yeah, Twitter is a moving target with fairly brittle interfaces.  Cheers, ~Ray
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question