?
Solved

Twitter api question/help needed

Posted on 2010-11-28
3
Medium Priority
?
253 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 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 111

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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 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