我需要下載(通過php:curl,file_get_contents ...)後整個圖片到網站文件夾。Facebook的PHP SDK V5 - 下載饋送後的全圖片
我能得到這個職位,項目數據,甚至full_picture URL,但是當我想通過wget來下載或捲曲的服務器有403
響應如果我嘗試下載的瀏覽器,網址,沒問題, 我能看到它。
https://scontent.xx.fbcdn.net/hvthumb-xta1/v/t15.0-10/s720x720/12525704_987920591279679_1409522552_n.jpg?oh=33b2b223cc3e6c2ddd1a94f098c44457&oe=5748C6D2
但是,如果我從捲曲或wget的嘗試,我得到一個401響應
wget https://scontent.xx.fbcdn.net/hvthumb-xta1/v/t15.0-10/s720x720/12525704_987920591279679_1409522552_n.jpg?oh=33b2b223cc3e6c2ddd1a94f098c44457&oe=5748C6D2
[1] 9988
[2] 9989
$ converted 'https://scontent.xx.fbcdn.net/hvthumb-xta1/v/t15.0-10/s720x720/12525704_987920591279679_1409522552_n.jpg?oh=33b2b223cc3e6c2ddd1a94f098c44457' (ANSI_X3.4-1968) -> 'https://scontent.xx.fbcdn.net/hvthumb-xta1/v/t15.0-10/s720x720/12525704_987920591279679_1409522552_n.jpg?oh=33b2b223cc3e6c2ddd1a94f098c44457' (UTF-8)
--2016-01-22 15:20:39-- https://scontent.xx.fbcdn.net/hvthumb-xta1/v/t15.0-10/s720x720/12525704_987920591279679_1409522552_n.jpg?oh=33b2b223cc3e6c2ddd1a94f098c44457
Resolving scontent.xx.fbcdn.net (scontent.xx.fbcdn.net)... 31.13.83.4, 31.13.83.4
Connecting to scontent.xx.fbcdn.net (scontent.xx.fbcdn.net)|31.13.83.4|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2016-01-22 15:20:39 ERROR 403: Forbidden.
我試過還追加訪問令牌路徑:
...&access_token=XXXXXXXX
這是json發表文章項目:
stdClass Object
(
[id] => 396231587217143_531401453700155
[created_time] => 2016-01-11T13:21:37+0000
...
[picture] => https://scontent.xx.fbcdn.net/hvthumb-xta1/v/t15.0-10/s130x130/12525704_987920591279679_1409522552_n.jpg?oh=34e4a1b419bb842c5f84441f9a781745&oe=574676AE
[full_picture] => https://scontent.xx.fbcdn.net/hvthumb-xta1/v/t15.0-10/s720x720/12525704_987920591279679_1409522552_n.jpg?oh=33b2b223cc3e6c2ddd1a94f098c44457&oe=5748C6D2
[attachments] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[media] => stdClass Object
(
[image] => stdClass Object
(
[height] => 405
[src] => https://scontent.xx.fbcdn.net/hvthumb-xta1/v/t15.0-10/s720x720/12525704_987920591279679_1409522552_n.jpg?oh=33b2b223cc3e6c2ddd1a94f098c44457&oe=5748C6D2
[width] => 720
)
)
[target] => stdClass Object
(
[id] => 10153413586308403
[url] => https://www.facebook.com/WorldArchery/videos/10153413586308403/
)
[type] => video_inline
[url] => https://www.facebook.com/WorldArchery/videos/10153413586308403/
)
)
)
...
)
我g以這種方式從Facebook頁面中發佈信息。
初始化Facebook類:
$this->facebook = new Facebook([
'app_id' => $app_id,
'app_secret' => $app_secret,
'default_graph_version' => 'v2.5',
//'default_access_token' => '{access-token}', // optional
]);
獲取post數據:
...
$fields = array(
'id',
'application',
'call_to_action',
'caption',
'created_time',
'description',
'from',
'icon',
'is_hidden',
'is_published',
'link',
'message',
'message_tags',
'name',
'object_id',
'picture',
'full_picture',
'place',
'privacy',
'properties',
'source',
'status_type',
'story',
'story_tags',
'targeting',
'to',
'type',
'updated_time',
'with_tags',
'actions',
// 'tags',
// 'object_attachment',
'feed_targeting',
'attachments',
);
$data = $this->facebook->get($id . '?fields=' . implode(',', $fields));
$item = json_decode($data->getBody());
$object (object) $item;
追加訪問令牌是沒有用的 - 您在此處未提出API請求,但正在從其CDN請求資源,並且不使用訪問令牌。 //你有沒有嘗試過添加「通常」的請求頭,讓你的請求看起來像來自一個真正的瀏覽器 - 諸如'User-Agent'之類的東西......? – CBroe