Superface

Publish Social Media Post

social-media/publish-post@2.0.1
5 providers

Publish a Post

Publish a post on a social media profile with optional image or video attachments.

Input
Profile ID
Text
Link
Title
Media attachments
Video IDs
Result
Post ID
Post URL

1.Choose a provider

2.Use PublishPost with mock in your code

Below instructions are for our Node.js SDK. Use OneService for other languages.
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('social-media/publish-post@2.0.1');

  // Use the profile
  const result = await profile
    .getUseCase('PublishPost')
    .perform({
      profileId: '110658944785122',
      text: 'Text of the Post.'
    }, {
      provider: 'mock'
    });

  // Handle the result
  try {
    const data = result.unwrap();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

run();

Structure details

Input (object)

profileId
Identifier of a profile to publish to. May be optional with some providers.
text
Text of the post
link
URL to attach to the post
title
Title of the post, if supported by the provider (e.g. Pinterest). Ignored otherwise.
media
Only images and gifs are supported
url
Will be fetched by provider, must be accessible publicly. If both `contents` and `url` fields are provided, a preferable option will be picked by the map.
contents
If both `contents` and `url` fields are provided, a preferable option will be picked by the map.
altText
Alternative text for screen readers
videos
IDs of previously uploaded videos (see `social-media/upload-from-url`) to be attached or published.

Example

{
  "profileId": "110658944785122",
  "text": "Text of the Post."
}

Result (object)

postId
Identifier of the published post.
url
Link to the published post.

Example

{
  "postId": "110658944785122_125682506616099",
  "url": "https://www.facebook.com/110658944785122/posts/125682506616099/"
}

Implementation details

Provider
mock
Use case
PublishPost
Author
@superface
Source
Verified