Solved

Twitter api question/help needed

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

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 110

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

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‚Ķ
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

690 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