내 Facebook 페이지에서 모든 게시물을 가져 오려고합니다. 페이지의 JSON 또는 RSS 형식으로 피드를 가져올 수 있지만 게시물의 이미지 링크를 식별하고 구문 분석하는 데 문제가 있습니다. 예를 들어 여기 내 페이지 Facebook Page JSON Feed의 JSON 피드에 대한 링크가 있습니다.Facebook (Page) JSON 또는 Rss 피드에서 이미지 링크 받기
다음은 사용자가 볼 수있는 형식입니다.
{
"title": "Shorts Fashion's Facebook Wall",
"link": "https:\/\/www.facebook.com\/",
"self": "https:\/\/www.facebook.com\/feeds\/page.php?id=717795881626394&format=json",
"updated": "2014-11-13T10:30:07-08:00",
"icon": "http:\/\/www.facebook.com\/favicon.ico",
"entries": [
{
"title": " Like <3",
"id": "78d3340189c23524385e0522f6336f03",
"alternate": "http:\/\/www.facebook.com\/717795881626394\/photos\/a.722551361150846.1073741829.717795881626394\/780062908733024\/?type=1",
"categories": [
],
"published": "2014-11-13T18:30:07+00:00",
"updated": "2014-11-13T18:30:07+00:00",
"author": {
"name": "Shorts Fashion"
},
"verb": "",
"target": "",
"objects": "",
"comments": "",
"likes": "",
"content": "Like \u2665\u003Cbr\/>\u003Cbr\/>\u003Ca href=\"\/717795881626394\/photos\/a.722551361150846.1073741829.717795881626394\/780062908733024\/?type=1&relevant_count=1\" id=\"\" title=\"\" target=\"\" onclick=\"\" style=\"\">\u003Cimg class=\"img\" src=\"https:\/\/scontent-b-kul.xx.fbcdn.net\/hphotos-xap1\/v\/t1.0-9\/s130x130\/10411933_780062908733024_2963383477612486789_n.jpg?oh=edcaf58eabb7f3fc88046bab3d5ddb5c&oe=54EA4DE2\" alt=\"\" \/>\u003C\/a>\u003Cbr\/>"
},
{
"title": " <3 <3<3 <3<3 <3",
"id": "adfedefb63af7a5443db66e19807f8fc",
"alternate": "http:\/\/www.facebook.com\/717795881626394\/photos\/a.722551361150846.1073741829.717795881626394\/780058738733441\/?type=1",
"categories": [
아래의 방법을 사용하면 게시물의 제목을 얻을 수 있지만 각 게시물에서 이미지 링크를 얻는 방법을 모르겠습니다. 제발 좀 도와주세요. 감사합니다
내 페이지 피드에서 이미지를 내 웹 사이트와 안드로이드 응용 프로그램에 표시 할 싶어$url = "http://www.facebook.com/feeds/page.php?id=717795881626394&format=json";
// disguises the curl using fake headers and a fake user agent.
function disguise_curl($url)
{
$curl = curl_init();
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: "; // browsers keep this blank.
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_REFERER, '');
curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($curl, CURLOPT_AUTOREFERER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
$html = curl_exec($curl); // execute the curl command
curl_close($curl); // close the connection
return $html; // and finally, return $html
}
// uses the function and displays the text off the website
$text = disguise_curl($url);
$json_feed_object = json_decode($text);
foreach ($json_feed_object->entries as $entry)
{
echo " {$entry->title}";
echo "<br>";
}
. 감사합니다
전체 코드를 추가 할 수 있습니까? PHP를 사용하여 피드를 가져 오는 데 문제가 있습니까? 감사합니다 – farhangdon
물론입니다. 당신은 거기에 당신이 정말로 필요 없어 많은 것을 가지고 ... – rjdown
공지 사항 : 라인 15에서 비 개체의 속성을 얻으려고합니다. 이 문제가 발생했습니다 :/ – farhangdon