function drupagram_media_save in Drupagram 7
Same name and namespace in other branches
- 6 drupagram.inc \drupagram_media_save()
Saves a InstagramMedia object to {drupagram}
2 calls to drupagram_media_save()
- drupagram_fetch_recent_items in ./
drupagram.inc - Fetches a user's recent items.
- drupagram_fetch_user_feed in ./
drupagram.inc - Fetches a user's feed
File
- ./
drupagram.inc, line 132 - Instagram API functions
Code
function drupagram_media_save($media) {
$drupagram = array(
'drupagram_id' => check_plain($media->id),
'username' => drupagram_emoji($media->user->username),
'type' => filter_xss($media->type),
// 'tags' => serialize($media->tags),
'images' => serialize($media->images),
'location' => serialize($media->location),
'comments' => serialize(drupagram_emoji($media->comments)),
'caption' => serialize(drupagram_emoji($media->caption)),
'link' => drupagram_emoji($media->link),
'likes' => serialize(drupagram_emoji($media->likes)),
'filter' => filter_xss($media->filter),
'created_at' => format_date($media->created_time, 'long'),
'created_time' => $media->created_time,
);
// Filter out any empty keys in our array.
$drupagram = array_filter($drupagram);
db_merge('drupagram')
->key(array(
'drupagram_id' => $drupagram['drupagram_id'],
))
->fields($drupagram)
->execute();
}