Solved

Twitter api question/help needed

Posted on 2010-11-28
3
247 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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 create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

777 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