Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Facebook API: Adding Action Links to Posts

Facebook API: Adding Action Links to Posts

0

Action Links are a good way to add an extra call to action (CTA) beside the Link and Share links on Facebook Posts. The actions parameter lets you add a custom link and name to any post on Facebook, whether is a CTA to download a file, or voting in a poll / competition.

Action Links in PHP

The below code demonstrates a simple API call that adds a message with a custom “Search” action to the post. The name and link attributes inside of the actions parameter can be changed to say anything. And you can even add the other feed parameters like name, link, caption, picture and description to customise the post further.

The above code results in a post like:

Facebook Action Links

Action Links in JavaScript

The below JavaScript example is a bit more elaborate, adding a link and related parameters to create a better post. The name, link, caption, and picture attributes are used to add a link to the post.

The above code results in a share dialog like:

Facebook JS Action Links Share Dialog

Demo

You can find a working example of the JavaScript code here. Click on the “Edit in JS Bin” button in the top-right corner to play around with the code too.

Facebook, Facebook Graph API, JavaScript, jQuery, PHP

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Firewall Flash Gadget Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy