Skip to content
Michael Haschke edited this page Aug 6, 2017 · 4 revisions

Instagram service class

The Instagram service aggregates the recent media from a Instagram user profile.

Configuration values

  • method: either InstagramApiData or InstagramProfileData
  • username: your Instagram username

... and the basic configuration for all services.

for InstagramApiData

  • access_token: the access token of your instagram client authorized by your Instagram user:
    1. Create your your Instagram client (it's easy to register one).
    2. Add a redirect URL under the security options (use a URL that you control, e.g. your homepage or the URL you use for your PubwichFork installation) and allow implicit OAuth.
    3. Use the implicit OAuth workflow of Instagram: https://api.instagram.com/oauth/authorize/?client_id=YOUR-CLIENT-ID&redirect_uri=YOUR-REDIRECT-URI&scope=basic+public_content&response_type=token
    4. use the access token from YOUR-REDIRECT-URI#access_token=YOUR-ACCESS-TOKEN

Using a client in API sandbox mode, you will be able to access the last 20 media of any sandbox user that grants you permission.

for InstagramProfileData

  • no other options

You only have access to the last 12 public media of the profile with the configured username.

Example configuration

$instagram = array(
    'Instagram', 'instagram', array(
                    'method' => 'InstagramApiData',
		'username' => 'username', // from https://instagram.com/username/
		'access_token' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
		'total' => 8,
		'title' => 'Instagram',
		'description' => 'recent media'
	)
);

Template keys

  • date: info about publishing time
  • title: given media title (first line of the media description)
  • link: URL of the Instagram page of the media
  • thumbnail: URL of the preview thumbnail
  • description: the full media description

Example template

<li>
    <a title="{{{title}}}" href="{{{link}}}">
        <img src="{{{thumbnail}}}" alt="{{{title}}}" height="75" />
    </a>
</li>