Platform API
This page assumes the app developer is familiar with Regular SDK Guidelines – if that’s not the case, please make sure to review the official Regular SDK guide before you continue to this page.
Setup SDK
Make sure to initiate Outbrain SDK by calling initializeOutbrain()
method with a partner key that is configured specifically for platforms (contact your AM or GTO for more details if needed). See example:
Outbrain.register(this, "PARTNER_KEY")
Create a Request
In order to generate a request for recommendations via the SDK, the app developer should create a new instance of OBPlatformRequest
with the following mandatory params:
- widget id
bundleUrl
orportalUrl
- lang (for example: “en”)
See the OBPlatformRequest constructor signature:
public OBPlatformRequest(String widgetId, String bundleUrl, String portalUrl, String lang) {
super(null, widgetId);
this.bundleUrl = bundleUrl;
this.portalUrl = portalUrl;
this.lang = lang;
}
See example
OBPlatformRequest platformRequestWithPortal = new OBPlatformRequest("SDK_1", null, OUTBRAIN_SAMPLE_PORTAL_URL, "en");
or
OBPlatformRequest platformRequestWithBundle = new OBPlatformRequest("SDK_1", OUTBRAIN_SAMPLE_BUNDLE_URL, null, "en");
Optional param – psub
psub
is a property on OBPlatformRequest
which publishers can set for an additional source breakdown available for platforms.
Optional param – newsFrom
newsFrom
is a property For Outbrain News - language of the news, for example "es"
Optional param – news
newsFrom
is a property For Outbrain News - list of sources, separated by comma ",", for example "IAB1,IAB3,IAB10"
Fetch Recommendations
After OBPlatformRequest
is created – the app developer can fetch recommendations by calling:
Outbrain.fetchRecommendations(platformRequest, this)