Afternoon,
I am using PHP Zend to search twitter API in order to find tweets with links, I can get the URL in the tweets using the entities array but I need to display the page title of the URL.
I am using DOMDocument() the following code below to get the title, is there any other way to get the URL title because it take an age for the page to load due to the pinging all the URL’s or is there some info in the twitter response I am missing?
function getTitle($Url){
$urlContents = file_get_contents($Url);
$dom = new DOMDocument();
@$dom->loadHTML($urlContents);
$title = $dom->getElementsByTagName('title');
return $title->item(0)->nodeValue; // "Example Web Page"
}
Thanks in advanced!
J.
If the following is indicative of the results you are working with.
Then it looks like some version of what you’re already doing is what you need. You can cache it either in a MySQL database or a flat-file. If you’re not familiar with either of those, make Google your friend. Cache won’t help initial load time, but will help the next time someone accesses the page
You might consider letting the page load without titles, then fill them in with an AJAX call.