這是我的代碼,但需要一個調整來解決它。我使用這種包裝https://github.com/cosenary/Instagram-PHP-API
require 'instagram.class.php';
$cache = './cache.json';
$instagram = new Instagram($accessToken);
$instagram->setAccessToken($accessToken);
$response = $instagram->getUserMedia($userID,$settings['count']);
do {
if($response){
file_put_contents($cache,json_encode($response)); //Save as json
}
} while ($response = $instagram->pagination($response));
echo 'finish';
有了這段代碼,我只得到最後的分頁。看起來代碼覆蓋了cache.json文件,而不是添加。 也許你可以建議我如何解決它變得添加,而不是覆蓋。
- 編輯 -
我的代碼現在的工作,但並不完美,也許你可以嘗試修復它。
<?php
include('conf.php');
require 'instagram.class.php';
$cache = './cache_coba.json';
$instagram = new Instagram($accessToken);
$instagram->setAccessToken($accessToken);
$response = $instagram->getUserMedia($userID,$settings['count']);
while ($response = $instagram->pagination($response)) {
if($response){
$opn = file_get_contents($cache);
$opn .= json_encode($response);
file_put_contents($cache, $opn);
}
}
echo 'finish';
?>
讓我們看看你的代碼,你試過了什麼? – cmorrissey
如果您將參數'&count = -1'添加到請求的末尾,您可以將完整的圖像列表視爲一個大文件。 – PlantTheIdea
不,params&count = -1你會失去許多值,如標題值爲空,評論和其他。 我沒試過。我只是有一個想法,可能會將商店全部實現爲一個文件,並且如果使用instagram帳戶進行更新只是觸發代碼重新獲取並存儲所有文件。 – cutez7boyz