Created
January 23, 2012 23:01
-
-
Save johnrobertwilson/1666187 to your computer and use it in GitHub Desktop.
media savw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Saves a InstagramMedia object to {drupagram} | |
*/ | |
function drupagram_media_save($media) { | |
// Cleanse the full_name field of bad chars | |
if (!empty($media)) { | |
if (!empty($media->likes)) { | |
if (!empty($media->likes['data'])){ | |
foreach ($media->likes['data'] as $index => $like_item) { | |
$media->likes['data'][$index]['full_name'] = stripslashes($like_item['full_name']); | |
} | |
} | |
} | |
} | |
$drupagram = array( | |
'drupagram_id' => $media->id, | |
'username' => $media->user->username, | |
'type' => $media->type, | |
// 'tags' => serialize($media->tags), | |
'images' => serialize($media->images), | |
'location' => serialize($media->location), | |
'comments' => serialize($media->comments), | |
'caption' => $media->caption, | |
'link' => $media->link, | |
'likes' => serialize($media->likes), | |
'filter' => $media->filter, | |
'created_at' => $media->created_time, | |
'created_time' => $media->created_time, | |
); | |
$drupagram = array_filter($drupagram); | |
db_merge('drupagram') | |
->key(array('drupagram_id' => $drupagram['drupagram_id'])) | |
->fields($drupagram) | |
->execute(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment