我已經做了一個模塊,顯示從instagram配置文件中的最新圖像,它完美的Joomla 3.4.8與一個小的彈出式庫 我想添加個人資料圖像 - profile_picture,但它當然應該只出現一次。 我曾嘗試過各種PHP的回聲 - 但沒有運氣如何從一個json文件只回聲一個職位
誰能幫助?
的PHP
<?php
// Supply a user id and an access token
$userid = $params->get('klintweb_insta_id');
$accessToken = $params->get('klintweb_insta_access_token');
$count = $params->get('klintweb_insta_count');
// Gets post and image
function fetchData($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;
}
// Pulls and parses data.
$result = fetchData("https://api.instagram.com/v1/users/{$userid}/media/recent/?count={$count}&access_token={$accessToken}");
$result = json_decode($result);
?>
在foreach
<?php foreach ($result->data as $post): ?>
{emailcloak=off}
<!-- Renders images. @Options (thumbnail,low_resoulution, high_resolution) -->
<span class="KlintWebInstaSpan">
<a data-mediabox-group="insta" type="image/jpeg" class="jcepopup noicon" data-mediabox-caption="<?= rtrim(strip_tags(substr ($post->caption->text,0,140))).'...'; ?>" data-mediabox-title="rasmusjorgensen128" href="<?= $post->images->standard_resolution->url ?>">
<img src="<?= $post->images->thumbnail->url ?>" alt="Billede fra instagram" />
<span class="overlay"></span>
</a>
</span>
<?php endforeach ?>
的jsonfile
{
"data": [{
"comments": {
"count": 0
},
"caption": {
"created_time": "1296710352",
"text": "Inside le truC#foodtruck",
"from": {
"username": "kevin",
"full_name": "Kevin Systrom",
"type": "user",
"id": "3"
},
"id": "26621408"
},
"likes": {
"count": 15
},
"link": "http://instagr.am/p/BWrVZ/",
"user": {
"username": "kevin",
"profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_3_75sq_1295574122.jpg",
"id": "3"
},
"created_time": "1296710327",
"images": {
"low_resolution": {
"url": "http://distillery.s3.amazonaws.com/media/2011/02/02/6ea7baea55774c5e81e7e3e1f6e791a7_6.jpg",
"width": 306,
"height": 306
},
"thumbnail": {
"url": "http://distillery.s3.amazonaws.com/media/2011/02/02/6ea7baea55774c5e81e7e3e1f6e791a7_5.jpg",
"width": 150,
"height": 150
},
"standard_resolution": {
"url": "http://distillery.s3.amazonaws.com/media/2011/02/02/6ea7baea55774c5e81e7e3e1f6e791a7_7.jpg",
"width": 612,
"height": 612
}
},
"type": "image",
"users_in_photo": [],
"filter": "Earlybird",
"tags": ["foodtruck"],
"id": "22721881",
"location": {
"latitude": 37.778720183610183,
"longitude": -122.3962783813477,
"id": "520640",
"street_address": "",
"name": "Le Truc"
}
},
{
"videos": {
"low_resolution": {
"url": "http://distilleryvesper9-13.ak.instagram.com/090d06dad9cd11e2aa0912313817975d_102.mp4",
"width": 480,
"height": 480
},
"standard_resolution": {
"url": "http://distilleryvesper9-13.ak.instagram.com/090d06dad9cd11e2aa0912313817975d_101.mp4",
"width": 640,
"height": 640
},
"comments": {
"count": 2
},
"caption": null,
"likes": {
"count": 1
},
"link": "http://instagr.am/p/D/",
"created_time": "1279340983",
"images": {
"low_resolution": {
"url": "http://distilleryimage2.ak.instagram.com/11f75f1cd9cc11e2a0fd22000aa8039a_6.jpg",
"width": 306,
"height": 306
},
"thumbnail": {
"url": "http://distilleryimage2.ak.instagram.com/11f75f1cd9cc11e2a0fd22000aa8039a_5.jpg",
"width": 150,
"height": 150
},
"standard_resolution": {
"url": "http://distilleryimage2.ak.instagram.com/11f75f1cd9cc11e2a0fd22000aa8039a_7.jpg",
"width": 612,
"height": 612
}
},
"type": "video",
"users_in_photo": null,
"filter": "Vesper",
"tags": [],
"id": "363839373298",
"user": {
"username": "kevin",
"full_name": "Kevin S",
"profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_3_75sq_1295574122.jpg",
"id": "3"
},
"location": null
},
] }
由於亞當·泰勒 你指出它是如何簡單可以做到
也感謝Danoweb幫助
正如你可以看到有URL中的「計數」。如果例如數爲4,畫廊顯示,從最新的4個帖子 我想顯示「profile_picture」一旦4個縮略圖 – KlintWeb