/** * * Unsubscribe to Instagram from a Link generated via the admin. Just forwards to the service. * * */ public function unsubscribe() { $is = new InstagramService(); if ($is->unsubscribeRealtime()) { return $this->redirect('admin/instagram-settings/InstagramSubscription/EditForm/field/InstagramSubscription/item/' . Session::get('InstaSub') . '/edit'); } else { throw new Exception('Unable to unsubscribe to Instagram. See logs for more info.'); } }
public function updatePosts($objectID = '') { $is = new InstagramService($this); $minID = $this->MinID; $update = false; switch ($this->Type) { case "tag": if (empty($objectID)) { $objectID = $this->HashTag; } $update = $is->tagsRecent($objectID, null, $minID); if ($update) { $this->MinID = $update->pagination->min_tag_id; } break; case "user": if (empty($objectID)) { $objectID = 'self'; } $update = $is->getUserRecent($objectID, null, null, null, $minID); if ($update) { $this->MinID = $update->data[0]->created_time; } break; } $callbackFunc = (string) Config::inst()->get('Instagram', 'postReceivedCallback'); if ($update) { $this->write(); foreach ($update->data as $img) { if (isset($img->id)) { $p = InstagramPost::get()->Filter(array('PostID' => $img->id)); if ($p->Count() == 0) { $p = new InstagramPost(); } else { $p = $p->first(); } if (!empty($img->tags)) { $p->setTags($img->tags); } $p->Caption = $img->caption->text; $p->Link = $img->link; $p->Posted = $img->created_time; $p->ImageURL = $img->images->standard_resolution->url; $p->PostID = $img->id; $p->Processed = false; $p->OrigMessage = json_encode($img); $p->Type = "Instagram"; $p->CommentCount = $img->comments->count; $p->LikeCount = $img->likes->count; $p->SubscriptionID = $this->ID; $p->write(); if (!empty($callbackFunc)) { $p->{$callbackFunc}(); } } } return true; } else { return false; } }