Solved

Twitter api question/help needed

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

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
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
Comment Utility
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 108

Expert Comment

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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now