インターネットやこのページで見たものを取り入れて、以下の Instagram クラス (非常にシンプルで、フィードをプルするためだけなど) を作成しました。
class Instagram {
public static $result;
public static $display_size = 'thumbnail'; // you can choose between "low_resolution", "thumbnail" and "standard_resolution"
public static $access_token = "DEFAULTACCESSTOKEN"; // default access token, optional
public static $count = 10;
public static function fetch($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function __construct($Token=null){
if(!empty($Token)){
self::$access_token = $Token;
// Remove from memory -- not sure if really needed.
$Token = null;
unset($Token);
}
self::$result = json_decode(self::fetch("https://api.instagram.com/v1/users/self/media/recent?count=" . self::$count . "&access_token=" . self::$access_token), true);
}
}
$Instagram = new Instagram('ACCESSTOKENIFCHANGEDORNULLOREMPTY');
foreach ($Instagram::$result->data as $photo) {
$img = $photo->images->{$Instagram::$display_size};
}