2014-10-06 36 views
1

我使用Facebook C#SDK爲我的項目的Facebook C#SDK給小Facebook發佈圖片

dynamic pageData = client.Get("/"+pageId+"/Posts", new { 
      access_token = _userAccesstoken 
     }); 
    var data = pageData[0]; 

在此,如果有圖片文章則比實物圖片貼在其上返回的圖片是小Facebook頁面。

例如這是我得到的圖片:

Actual

Original small image url

但是,這是真實的情況,我應該得到:

Desired

Original large image url

請問有什麼需要改變?

+0

沒有人有這個問題嗎? – 2014-10-07 14:31:25

回答

0

,我已經得到了唯一的解決辦法,就是使用圖形API返回的是隻包含圖片的鏈接,網頁和搜索頁此字符串:

<a class="fbPhotosPhotoActionsItem" href="https:// 

這將返回原來的圖像,你可以下載。這是PHP中的工作代碼:

function getFullImageURL($url) { 
    $crawlerHelper = new CrawlerHelper(); 
    $response = $crawlerHelper->httpRequest($url); 
    $html = $response->getHtml(); 

    $imageLink = explode('<a class="fbPhotosPhotoActionsItem" href="https://', $html); 
    if (count($imageLink) == 2) { 
     $imageLink = explode('"', $imageLink[1]); 
    } else { 
     // This could mean other type of post, like video 
     echo 'Image not found'; 
     return; 
    } 

    return 'https://'.str_replace('?dl=1', '', html_entity_decode($imageLink[0]));  
} 
相關問題