2012-02-19 154 views
1

目前,我正在顯示來自地理編碼以及tweet本身的推文以及用戶名和推文的時間和日期。但現在我試圖訪問XML內的個人資料圖片。我已經訪問鏈接標籤中包含的狀態鏈接。顯示來自XML文件的Twitter個人資料圖片

這是我試圖訪問的標籤。

<link type="image/png" href="http://a0.twimg.com/profile_images/1706928570/IMG00474-20111008-1737_normal.jpg" rel="image" > 

XML文件中的位置是18行

<feed xmlns:google="http://base.google.com/ns/1.0" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.w3.org/2005/Atom" xmlns:twitter="http://api.twitter.com/" xmlns:georss="http://www.georss.org/georss" xml:lang="en-US" > 
    <id>tag:search.twitter.com,2005:search/</id> 
    <link type="text/html" href="http://search.twitter.com/search?q=" rel="alternate" > 
    <link type="application/atom+xml" href="http://search.twitter.com/search.atom?q=" rel="self" > 
    <title>- Twitter Search</title> 
    <link type="application/opensearchdescription+xml" href="http://twitter.com/opensearch.xml" rel="search" > 

    <link type="application/atom+xml" href="http://search.twitter.com/search.atom?since_id=170944502142476289&q=&geocode=51.5069999695%2C-0.142489999533%2C10.0mi%22london%22" rel="refresh" > 
    <updated>2012-02-18T18:55:19Z</updated> 
    <openSearch:itemsPerPage>15</openSearch:itemsPerPage> 
    <link type="application/atom+xml" href="http://search.twitter.com/search.atom?page=2&max_id=170944502142476289&q=&geocode=51.5069999695%2C-0.142489999533%2C10.0mi%22london%22" rel="next" > 
    <entry> 
      <id>tag:search.twitter.com,2005:170944502142476289</id> 
      <published>2012-02-18T18:55:19Z</published> 
      <link type="text/html" href="http://twitter.com/LondITjobs/statuses/170944502142476289" rel="alternate" > 
      <title>Software Development Engineer II - London #job #jobs #hiring #career http://t.co/VsxPdWdT</title> 
      <content type="html" >Software Development Engineer II - London #job #jobs #hiring #career http://t.co/VsxPdWdT</content> 
      <updated>2012-02-18T18:55:19Z</updated> 
      <link type="image/png" href="http://a3.twimg.com/profile_images/1812202768/jr_100_normal.png" rel="image" > 
      <twitter:geo> 
      <google:location>London</google:location> 
      <twitter:metadata> 
       <twitter:result_type>recent</twitter:result_type> 
      </twitter:metadata> 
      <twitter:source>twitterfeed</twitter:source> 
      <twitter:lang>en</twitter:lang> 
      <author> 
       <name>LondITjobs (ITjobsLondon)</name> 
       <uri>http://twitter.com/LondITjobs</uri> 
      </author> 
     </entry> 

這裏是我的代碼,我現在有..

<?php function get_twitter($feed) { 

$xml = new SimpleXmlElement(file_get_contents($feed)); 


foreach ($xml->entry as $item) { 

    $date = date("D, dS M Y g:i:sA T", strtotime($item->published)); 

    echo '<a href="' . $item->link->attributes()->href . '" target="_blank">' . $item->title . '</a><br />' .'<img src='.$item->link->link->attributes()->href .'/>'.'<br />'. $item->author->name . '<br />' . '<strong>' . $date . '</strong>' . '<br />'; 
} 

} 

?> 

目前,我已經訪問的第一個鏈接標記XML和Im的入口部分有點不確定如何訪問圖片。我想過做鏈接[0],但不知道這是否應該走。有什麼建議麼?

Heres what I currently have

回答

0

終於研究出瞭解決辦法。

'<img src="http://api.twitter.com/1/users/profile_image/' . $item->author->name .'" width="55" height="55"'. '>' . '</a>' 

用戶名解析到URL的末尾,然後超鏈接回用戶的配置文件。所有圖片都是有限的,以確保一致性。

相關問題