I've come to some problems. I've made a wordpress plugin, which automatically gets the most 20 recent Instagram posts and then, in theory, it should make me let to insert the newest image as a shortcode in to the post. Basically, I get an error message displaying:
Notice: Uninitialized string offset: 0 in D:\XEMP\htdocs\xd\wordpress\wp-content\plugins\insta-live\insta-live.php on line 29
Now, the code to reproduce this is:
//define Access token
$accesst= "PUT YOUR INSTAGRAM ACCESS TOKEN HERE";
//userid
$userid= YOUR INSTAGRAM USER ID HERE;
//image count to get
$count=20;
//get api contents
$content = file_get_contents('https://api.instagram.com/v1/users/self/media/recent/?access_token='.$accesst.'&count='.$count);
//converting JSON to object
$standardres = json_decode($content, true);
//array method
foreach($standardres['data'] as $photo) {
$imageData = base64_encode(file_get_contents($photo['images']['standard_resolution']['url']));
$images[] = '<img src="data:image/jpeg;base64,' . $imageData . '" />';
}
//create functions for shortcodes
function fone($images){
return $images[0]; //naudok tik [one]
}
//shortcodes
add_shortcode( 'one', 'fone');
?>
Any ideas how to solve this? A var_dump()
gives me the images above the header..