[PRO] PHP API

The PRO version of Spotlight includes a developer API that can be used to create custom feeds and solutions for you or your clients. It is accessible from the SpotlightInstagram class.

If you'd rather look at code than documentation, take a look at the includes/pro.php file that is bundled with the PRO version of the plugin.

Usage

Get posts for a feed

SpotlightInstagram::getFeedMedia(int $feedId, int $num, int $offset)

Arguments:

  1. $feedId - The ID of the feed whose posts you want to retrieve.
  2. $num - Optional number of posts to retrieve. If not given, the number of posts that is returned is determined by the feed's options
  3. $offset - Optional number of posts to skip over. If not given, no posts will be skipped and the first post in the returned list will be the first post in the feed.

Returns:

An array of IgCachedMedia objects.
Refer to the  Object Reference section towards the bottom of this page.

Get stories for a feed

SpotlightInstagram::getFeedStories(int $feedId)

Arguments:

  1. $feedId - The ID of the feed whose stories you want to retrieve.

Returns:

An array of  IgCachedMedia objects.
Refer to the  Object Reference section towards the bottom of this page.

Get feed options

SpotlightInstagram::getFeed(int $feedId)

Arguments:

  1. $feedId - The ID of the feed

Returns:

A Feed object. Refer to the Object Reference section towards the bottom of this page.

Object Reference

IgCachedMedia

This object represents a cached Instagram media post and consists of the following properties:

id int The Instagram ID of the post.
username string The username of the Instagram user that owns this post.
timestamp DateTime The timestamp for when the post was posted on Instagram.
caption string The caption of the post as plain text (hashtags, mentions and other links are not processed into HTML links).
type string One of the following: "IMAGE", "VIDEO" or "CAROUSEL_ALBUM".
url string The URL to the full size image or video that is hosted by Instagram's CDN.
permalink string The URL to the post's page on instagram.com.
shortcode string The unique permalink code for the Instagram post.
thumbnail string The URL to Instagram's thumbnail for the post's image or video.
If the post is a " CAROUSEL_ALBUM", the thumbnail will represent the first image in the album.
thumbnails array An associative array containing the URLs to the small and medium thumbnails that are generated by Spotlight.
The array contains 2 keys: s and m, which stand for "small" and "medium" respectively.
likesCount int The number of likes on the post.
commentsCount int The number of comments on the post.
comments Comment[] A list of comment objects.
children ChildMedia[] A list of children media posts.
This list is only used for "CAROUSEL_ALBUM" posts and is empty for "IMAGE" and "VIDEO" posts.
lastRequested int A timestamp of when the post was last fetched and shown on the site.
source MediaSource Deprecated. Starting from v0.9, this field is equivalent to "sources[0]".
sources MediaSource[] A list of the sources (accounts or hashtags) for which the Instagram post was fetched.
post WP_Post The WordPress post that is used for storing the information about the Instagram post.
Refer to the WP_Post docs on the WordPress Codex for more info.

Comment

Represents a comment on an Instagram post

id int The Instagram ID of the comment.
username string The username of the Instagram user that posted the comment.
text string The text content of the comment.
timestamp DateTime The timestamp for when the comment was posted.
likeCount int The number of likes on the comment.

ChildMedia

Represents an image or video that is part of an album (a post with type "CAROUSEL_ALBUM")

id int The Instagram ID of the media.
type string One of the following: " IMAGE", "VIDEO".
url string The URL to the full-size image or video that is hosted by Instagram's CDN.

MediaSource

Represents the source that was used to fetch an Instagram post.

name string The name of the source.
If the post was fetched for an account, this will be equal to the username of that account (without the "@").
If the post was fetched for a hashtag, this will be equal to the hashtag (without the "#").
type string The source type. One of the following:
  • PERSONAL_ACCOUNT
  • BUSINESS_ACCOUNT
  • TAGGED_ACCOUNT
  • POPULAR_HASHTAG
  • RECENT_HASHTAG

Feed

Represents a user-created feed.

id int The ID of the feed.
name string The user-given name to the feed.
options array An associative array containing the feed's options.
We recommend that you `var_dump` or this array to better understand its contents.
Did this answer your question? Thanks for the feedback! There was a problem submitting your feedback. Please try again later.

Still need help? Contact us Contact us