所以我找到了一个我想要下载图片的页面的完美示例,这恰好是http://www.habbo.com/habbo-imaging/avatarimage?figure=ch-215-110.hd-180-7.lg-275-110.hr-893-61&direction=3&head_direction=3&headonly=1&gesture=sml&size=1
现在,如果您要在桌面上保存图像,它会读取为PNG文件,虽然我尝试使用PHP保存它,但我希望它保存为GIF。
到目前为止我所做的是:
$ch = curl_init('https://www.habbo.com/habbo-imaging/avatarimage?figure=hr-125&direction=3&head_direction=3&headonly=1&gesture=sml&size=1');
$fp = fopen('game/c_images/badges/' . $badge_id . '.gif', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
我设法获得了权限并保存了图片,但它只保存了文件名并且照片不在那里。因此,我猜测它与我将PNG文件另存为GIF有关,当然还有我缺少的东西。
答案 0 :(得分:1)
是的,您可以使用html dom保存图像。 喜欢使用
// facebook SDK startup
$fb = new Facebook\Facebook([
'app_id' => '[my_app_id]',
'app_secret' => '[my_app_secret]',
'default_graph_version' => 'v2.4',
]);
$request = $fb->request('GET', '/{conversation-id}', array('fields' => 'gender'));
// Send the request to Graph
try {
$response = $fb->getClient()->sendRequest($request);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
var_dump($graphNode);