Source
A source connects to one social media provider, such as Instagram or YouTube, and fetches posts from it. Whenever you’re dealing with a source in your template, you’re working with a Source object. Fetch one by its handle, or get the sources in a feed with feed.getSources().
{% set source = craft.socialFeeds.getSourceByHandle('mySourceHandle') %}
{% if source and source.isConnected() %}
{% for post in source.getPosts({ limit: 5 }) %}
{{ post.getContent() }}
{% endfor %}
{% endif %}
Properties
The ID of the source.
The name of the source, as shown in the control panel.
The handle of the source, used to fetch it in templates and console commands.
Whether the source is enabled.
The date the source last fetched posts from its provider. This is null when the source hasn’t fetched yet or its cache was cleared.
The display name of the source’s provider, such as YouTube. This reads getProviderName().
The handle of the source’s provider, such as youTube. Posts from this source store it as their sourceType.
The provider’s brand colour as a hex value, such as #ff0000. This reads getPrimaryColor().
The provider’s icon as SVG markup. This reads getIcon().
The URL to edit the source in the control panel.
Methods
Returns whether the source has both a client ID and client secret saved.
Returns whether the source is connected to its provider with a saved access token.
Returns the source’s saved access token, or null when it isn’t connected.
Returns: array|null
Returns the source’s Post objects. When the cache is enabled, posts come from the database and are refreshed from the provider once the cache duration has passed.