How to setup up Ayrshare API to post on social media on behalf of your users

Hey, all you wonderful no-coders out there.

Last month I set up the API connection to Ayrshare allowing us to post (and schedule) on social media on behalf of our users.

We now have 346 users connected and are thrilled with it so far. @gbourne and his team have been very helpful on supporting me through the process, and I want to share my set-up, so you can give it a go too.

Ayrshare account and API key

Before starting, you have to create an account with Ayrshare to get your API key. If you want to post on behalf of your users, you’ll need a Business plan: Business Plan For Multiple Users | APIs for Social Media Posting

API connector
They do have a plugin if you just want to use it for yourself, but if you want to post on behalf of your users, you’re going to have to set up via the API connector. No worries if you haven’t done this before, it’s actually straightforward once you start.

how to set it up

  • open the Plugins tab
  • click on API Connector
  • Add another API > give it a name (I called mine Ayrshare)
  • Set Authentication to “None or self-handled”
  • In the shared headers for all calls, add two shared headers
    Key: Authorization Value: Bearer (your API key)
    (don’t forget to add Bearer in front if you want this to work.)
    Key: Content-Type Value application/json

Adding the calls

Depending on how you’re going to use the API, you’ll want to create several calls.
You’ll find the list of available calls in their documentation here: Endpoints - Ayrshare Docs

how to create a new call

  1. click on “Add another call”
  2. give it a name (mine all start with Ayrshare + call type)
  3. select Use as “Action” if you want to able to use it in the workflow, or “Data” to just get the data
  4. data type for this set up is always JSON
  5. POST or GET depending on the type of call you’re setting up and URL for the call (you’ll find this in the documentation)
    Note, when you copy the URL from the documentation, there is often a space in the URL. Remove it of the call won’t work.
  6. Headers you can leave blank as we’ve added them at the top
  7. Body Type - for this setup is JSON
  8. Parameters & Body > see setups below
    note: you’ll want to activate “include errors” and “capture response headers” to get messages back in case something goes wrong.
  9. When you’ve finished setting up the call elements, click on Initialize Call to test the setup and start using the API call.
    If there is a problem with the set-up, you’ll get a message from the server.

Here are the main calls I set up for reference and the ones with some “unique needs”.
Once you’ve done a few, the others mainly follow the same rules :slight_smile:

Create user profile (documentation)

Generate a JWT (documentation)
You will get the domain name and the key from Ayrshare upon signup. I recommend to keep these private.
The profile key is unique to each user - uncheck private so you can add this dynamically on each call. You can get that from the Ayrshare account when setting up under user profile > profile key.

Post (documentation)

Analytics (documentation)
In the platforms field, enter the names like this: “facebook”, “instagram”, “twitter” (currently no stats on linkedin, so if you add that platform there will be an error).

GET Comments (documentation)
This setup is a little different as the parameters are added to the URL instead of the body.

Those are the main ones I needed help with. The others so far were quite straightforward.

Once you’ve set this up, here is an article to help with the next steps: How To Create A Social Media Scheduling App With No Code

I hope this was helpful and will continue updating as I continue my Ayrshare journey :slight_smile:
Happy posting !

8 Likes

Thanks for this, Dee! I’ve been looking at this for my own SM campaigns but wondered how to configure each post for the different platforms.

5 Likes

Thanks @dee we were able to setup all the calls except generate JWT,
Everything works fine in POSTMAN though.

1 Like

I had a few issues setting that one up because of the Key. Probably best is to reach out to @gbourne who can help you with that.

Hi @technoswift - here are the Bubble-specific instructions on how to generate the JWT Token.
https://docs.ayrshare.com/packages/bubble.io#generate-jwt-token-in-bubble

4 Likes

Thank you @ayrshare team, this works perfectly.

3 Likes

Can I connect to Discord with this plugin? Maybe, JWT is the way to go?

I am having trouble with the delete post for my apps’ users. Has anyone been able to solve this? @ayrshare @dee

Hi @dbom009 -

To delete a post you can send the post ID to the DELETE Post endpoint.

Here is more info: https://docs.ayrshare.com/rest-api/endpoints/post#delete-a-post

Thanks!

Hi, I have been trying this but I keep getting a “Delete ID not found”. I have tried every single id that is returned from the post API call.

On this page https://docs.ayrshare.com/rest-api/endpoints/post

Click the > next to the api endpoint to expand it.
Then click the > next to the 200 response.

You can see the sample response. Use the id that the arrow is pointing to…

Thank you for this explanation. I tried this Id and it looks to be working. Appreciate the quick response.

1 Like

Hi @dee @ayrshare

Thank you so much for this tutorial! It’s really helpful. I’m stuck on the “post” call. I’m following exactly your body and meet the issue “Twitter is not linked with Ayrshare. Please confirm the linkage on the Social Accounts page in your dashboard.”

What might be a problem? I tried to connect Twitter through the dashboard but still had the same issue. And moreover I want to post on my users behalf. Why do I need to connect my twitter? I would be really grateful if you could give a hint where should I look for my solution

Here is the body of the call
{
“profileKeys”: ["< profileKeys >"],
“post”: “< post >”,
“platforms”: ["< platforms >"],
“mediaUrls”: ["< mediaUrls >"]
}

You need to go to the dashboard at app.ayrshare.com and connect your Twitter account before you can post to it. If you continue have an issue, please contact Ayrshare support directly at support@ayrshare.com.

Thank you! Twitter is connected, but the issue is still persistent. So I’ll contact support :slight_smile:
Twitter should be connected even if I want to post on the user’s behalf, right?