2010-09-01 68 views
0

嘗試檢索博客文章並將內容打印到網站。我從文檔中使用printfeed方法,但似乎只是打印標題。我需要標題,正文,照片,評論等。Google Blogger集成

function printFeed($feed) 
{ 
    $i = 0; 
    foreach($feed->entries as $entry) { 
     print $i ." ". $entry->title->text . "\n"; 
     $i++; 
    } 
} 

我用print_r()就把這個數組放在變量上只是亂七八糟。我找不到任何關於此的信息。我也使用查詢功能來限制我的數據,並引發錯誤。任何人有任何想法?

回答

1

爲了進行測試,你應該能夠使用toArray()功能

print_r($entry->toArray());

這應該告訴你的變量。您可以使用與標題相似的對象格式訪問它們:

echo $entry->body; 

希望這會有所幫助。您需要添加您希望打印的其他項目。 上面的toArray()方法是作爲一個例子,但如果你更容易理解如何工作一個數組,你可以將它分配給一個變量,但該對象也應該工作得很好。

編輯

我錯了有關toArray()電話。或者,$entry->body$entry->body->text能爲您提供您需要的信息嗎?

+0

toArray()拋出異常。 「toArray未在Gdata庫中找到......」 – kbrin80 2010-09-02 12:39:51

+0

種植園建築 致命錯誤:未在/ home/plant/public_html/includes/classes/Zend /包含消息'Property body not exists'的未捕獲異常'Zend_Gdata_App_InvalidArgumentException' Gdata/App/Base.php:484 Stack trace:#0 /home/plant/public_html/skin/plantation-building.php(25):Zend_Gdata_App_Base - > __ get('body')#1/home/plant/public_html/index.php(236):include('/ home/plant/pub ...')#2 {main}在線投入/home/plant/public_html/includes/classes/Zend/Gdata/App/Base.php 484 – kbrin80 2010-09-03 12:30:04