Hey all,
Like I said in my previous post, what I'm trying to do is essentially
create a site that lists my "friends_timeline." With that account, I'm
following a group of individuals in a particular industry.

Instead of hitting the Twitter server each time, I'm attempting to
store friends' tweets in a MySQL database and then display them to
visitors with PHP.

So, first off, I managed to authenticate and pull down the XML just
fine with curl.

As a test, I've stripped the data I want out and am printing it.

--------------------------------------------------------
//print XML data (temporary)
$xml = simplexml_load_string ($str);
foreach ($xml->status as $status) {
        print $status->created_at . "<br />\n"; //timestamp
        print $status->text . "<br />\n"; //body
        print $status->favorited . "<br />\n"; //favorited (returns true or
false)
        print $status->user->name . "<br />\n"; //user's real name
        print $status->user->description . "<br />\n"; //user's description
        print $status->user->profile_image_url . "<br />\n"; //location of
user's profile pic
        print $status->user->url . "<br />\n"; //user's homepage
        print $status->id . "<br /><br />\n"; //tweet single id
}
--------------------------------------------------------

And that works just fine.

For the next step, I've created a database and set up its table
structure to match the XML data.

Each line below represents a column in the table. For readability,
I've matched the XML data I've stripped from "friends_timeline" to
what I set up as its corresponding column in the database.
--------------------------------------------------------
//auto increment id (not matched with XML) (int)
//created_at -> time (text)
//text -> body (text)
//favorited -> favorited (enum)
//name -> name (text)
//description -> description (text)
//profile_image_url -> avatar (text)
//url -> url (text)
//id -> twitterid (int)
--------------------------------------------------------

Now, the part I'm stuck on: (1) I'm not sure how to get that XML data
into my database. Do I have to pass it through an array first? Do I
have to convert it to strings, or have I done that already with "$xml
= simplexml_load_string ($str)"?

The other issue I'm not sure about: (2) When a visitor comes to the
site, he'll see a "friends_timeline" from the data in the database,
not directly from twitter's servers. But how do I keep pulling data
from the XML feed and load it into the database automatically? And
what's a good interval to repeat

After the data starts populating my database, I don't think I'll have
too much trouble writing queries to display the content. But I'll
cross that bridge when I come to it. :D

I know this isn't explicitly a twitter API question, and I hope its
not out of place here. But any advice is appreciated. And sorry for
any improper terminology or poor explanations; as you can probably
tell, my web coding acumen isn't extensive.

Thanks in advance for the help!

--Alex

Reply via email to