SNAP API Documentation

SNAP API Documentation

How to use API

There are tree ways of using SNAP Universal API.

1. Using universal class cl_nxsAutoPostToSN that allows to post to all (or some) configured networks using settings array.

2. Calling each network’s API connector.

3. Calling each network’s API directlyGoogle+, Instagram, Pinterest, LinkedIn, Fliboard, XING Only) .

Message

This describes the message that could be passed to universal class or API connectors.

Message:

$message = array(
  'pTitle'=>'', 
  'pText'=>'', 
  'announce'=>'', 
  'url'=>'', 
  'surl'=>'', 
  'urlDescr'=>'', 
  'urlTitle'=>'', 
  'imageURL' => array(), 
  'videoCode'=>'', 
  'videoURL'=>'', 
  'siteName'=>'', 
  'tags'=>'', 
  'cats'=>'', 
  'authorName'=>'', 
  'orID'=>''
);

pTitle – Message title.
pText – Message body.
announce – Message excerpt.
url – URL of the linked or attached page.
surl – Shortened URL of the linked or attached page.
urlTitle – Title of the URL
urlDescr – Description of the URL
imageURL = URL or array [thumb, medium, large, original] – Array of images.
videoCode – code of the youtube video. For example for https://youtu.be/Dy6MpsDPKts code will be Dy6MpsDPKts
videoURL – URL of the video
siteName – Name of the site
tags – Tags
cats – Categories.
authorName – name of the original article author.
orID – ID of the original article

1. Using universal class cl_nxsAutoPostToSN that allows to post to all (or some) configured networks using settings array.

Networks array can be created manually, using “Management Panel” or exported from SNAP WordPress Plugin.

1. Post simple text message to all your configured accounts:

<?php        
  require_once "../nxs-snap-class.php";
  // First, let's get settings. 
  $fileData = file_get_contents(dirname(__FILE__).'/nx-snap-settings.txt');  
  $snapOptions = maybe_unserialize($fileData);
  
  if (class_exists("cl_nxsAutoPostToSN")) { 
    // Initialize the class
    $nxsAutoPostToSN = new cl_nxsAutoPostToSN($nxs_snapAPINts, $snapOptions);    
    // Message array contains the post
    $message = array(
      'title'=>'Social Networks Auto Poster (SNAP) API', 
      'text'=>'Social Networks Auto Poster (SNAP) API is
         a universal API for the most popular social networks', 
    );  
    // Set message 
    $nxsAutoPostToSN->setMessage($message);
    // Make the post
    $ret = $nxsAutoPostToSN->autoPost(); 
  }
?>

2. Post a text message with attached link and specific image ONLY to the first and third Twitter accounts and to the first Facebook account:

<?php       
  require_once "../nxs-snap-class.php"; 
  // First, let's get settings. 
  $fileData = file_get_contents(dirname(__FILE__).'/nx-snap-settings.txt');  
  $snapOptions = maybe_unserialize($fileData);
  $postOnlyTo = array('tw'=>array(0, 2), 'fb'=>array(0));
  $snapOptions= nxs_filterOutSettings($postOnlyTo, $snapOptions);
  
  if (class_exists("cl_nxsAutoPostToSN")) { 
    // Initialize the class
    $nxsAutoPostToSN = new cl_nxsAutoPostToSN($nxs_snapAPINts, $snapOptions);
    // Message array contains the post
    $message = array(
      'url'=>'https://www.nextscripts.com/snap-api/',
      'urlDescr'=>'Social Networks Auto Poster (SNAP) API', 
      'urlTitle'=>'Social Networks Auto Poster API', 
      'imageURL' => array(
        'large'=>'https://www.nextscripts.com/images/SNAP-Logo_Big_SQ.png'
      ), 
      'title'=>'Social Networks Auto Poster (SNAP) API', 
      'text'=>'Social Networks Auto Poster (SNAP) API is
         a universal API for the most popular social networks', 
    );  
    // Set message 
    $nxsAutoPostToSN->setMessage($message);
    // Make the post
    $ret = $nxsAutoPostToSN->autoPost(); 
  }
?>

2. Calling each network API connector directly.

You can also post directly to individual networks using API Connectors. You can do it with or without(Google+, Pinterest, LinkedIn Only) settings array.

Google+

Settings array:

gpUName – Google username
gpPass – Google password
gpPageID – (Optional) Google+ Page ID
gpCommID – (Optional) Google+ Community ID
gpCCat – (Optional) ID of the Google+ Community Category
postType – A or I or T – Type of the Google+ post: “A” – Attached URL, “I” – Image post, “T” – text only post.

Examples:

Using API Connector

<?php        
  require_once "nxs-functions.php";  require_once "inc-cl/gp.api.php"; 

  $message = array(
      'url'=>'https://www.nextscripts.com/snap-api/',
      'text'=>'Social Networks Auto Poster (SNAP) API is
         a universal API for the most popular social networks', 
  ); 

  $NToptions = array();
  $NToptions['gpUName'] = 'YourUsername@gmail.com';
  $NToptions['gpPass'] = 'YourPassword';
  $NToptions['postType '] = 'A';
  $NToptions['gpPageID'] = '114111009058659350987';

  $ntToPost = new nxs_class_SNAP_GP(); 
  $result = $ntToPost->doPostToNT($NToptions, $message);   
  
  if (!empty($result) && is_array($result) && !empty($result['postURL'])) 
    echo '<a target="_blank" href="'.$result['postURL'].'">New Post</a>'; 
  else 
    echo "<pre>".print_r($result, true)."</pre>";
?>

Direct API Call

Here is the example of how to post a simple message to your Google Plus Business Page Stream: (more examples of using it with Google+ only are here Google+ Automated Posting)

<?php        
  require_once "nxs-api/nxs-api.php"; 

  $email = 'YourUsername@gmail.com'; 
  $pass = 'YourPassword';
  $pageID = '114111009058659350987';
  $msg = 'Post this to Google Plus!'; 

  $nt = new nxsAPI_GP();
  $loginError = $nt->connect($email, $pass);     
  if (!$loginError)
    {
      $result = $nt -> postGP($msg, '', $pageID);
    } 
  else echo $loginError; 
  
  if (!empty($result) && is_array($result) && !empty($result['post_url'])) 
    echo '<a target="_blank" href="'.$result['post_url'].'">New Post</a>'; 
  else 
    echo "<pre>".print_r($result, true)."</pre>";
?>

Facebook

Settings array:

fbURL – URL of the facebook page. Could be profile, business page or group.
appKey – Facebook APP ID
appSec – Facebook APP Secret
accessToken – Facebook Authorization Token.
pageAccessToken – Facebook Page Authorization Token. (required for posting to business page only)
postType – A or I or T – Type of the Facebook post: “A” – Attached URL, “I” – Image post, “T” – text only post.
attachType – A or S – (“Attached URL” post type only) Type of the attached URL: “A” – Attached, “S” – Shared.
imgUpl – T or A – (“Image” post type only) Where to upload image: “T” – Timeline, “A” – Album.

Here is how to post to Facebook:

Using API Connector

<?php        
  require_once "nxs-functions.php";  require_once "inc-cl/fb.api.php"; 

  $message = array(
      'url'=>'https://www.nextscripts.com/snap-api/',
      'urlDescr'=>'Social Networks Auto Poster (SNAP) API', 
      'urlTitle'=>'Social Networks Auto Poster API', 
      'imageURL' => array(
        'large'=>'https://www.nextscripts.com/images/SNAP-Logo_Big_SQ.png'
      ), 
      'pTitle'=>'Social Networks Auto Poster (SNAP) API', 
      'pText'=>'Social Networks Auto Poster (SNAP) API is
         a universal API for the most popular social networks', 
  ); 

  $NToptions = array();

  $NToptions['fbURL'] = 'https://www.facebook.com/MYFBPAGE';
  $NToptions['appKey'] = 'APPID';
  $NToptions['appSec'] = 'SEC';
  $NToptions['accessToken'] = 'user_token';
  $NToptions['pageAccessToken'] = 'page_token'; //## If you are posting to a page
  $NToptions['postType'] = 'A';

  $ntToPost = new nxs_class_SNAP_FB(); 
  $result = $ntToPost->doPostToNT($NToptions, $message);   
  
  if (!empty($result) && is_array($result) && !empty($result['postURL'])) 
    echo '<a target="_blank" href="'.$result['postURL'].'">New Post</a>'; 
  else 
    echo "<pre>".print_r($result, true)."</pre>";
?>

Twitter

Settings array:

appKey
appSec
accessToken
accessTokenSec

Here is how to post to Twitter:

<?php        
  require_once "nxs-functions.php";  require_once "inc-cl/tw.api.php"; 

  $message = array();
  $message['pText'] = 'Test Post';
  $message['imageURL'] = 'https://www.nextscripts.com/imgs/nextscripts.png';

  $TWoptions = array();

  $TWoptions['twURL'] = 'https://twitter.com/YourTWPage';
  $TWoptions['appKey'] = 'KEY';
  $TWoptions['appSec'] = 'SECRET';
  $TWoptions['accessToken'] = 'TOKEN';
  $TWoptions['accessTokenSec'] = 'TOKENSECRET';
  $TWoptions['attchImg'] = '1';

  $ntToPost = new nxs_class_SNAP_TW(); 
  $result = $ntToPost->doPostToNT($TWoptions, $message);   
  
  if (!empty($result) && is_array($result) && !empty($result['postURL'])) 
    echo '<a target="_blank" href="'.$result['postURL'].'">New Post</a>'; 
  else 
    echo "<pre>".print_r($result, true)."</pre>";
?>

Blogger

Settings array:

bgUName
bgPass
bgBlogID
bgInclTags

DIIGO

Settings array:

diUName
diPass
diAPIKey

Delicious

Settings array:

dlUName
dlPass

FriendFeed

Settings array:

ffUName
ffPass
grpID
imgToUse

InstaPaper

Settings array:

ipUName
ipPass

LinkedIn

Settings array:

ulName
uPass
uPage
grpID
liAPIKey
liAPISec
liOAuthVerifier
liOAuthToken
liOAuthTokenSecret
liAccessToken
liAccessTokenSecret
liAttch

Management panel

(SNAP API PRO only). Upload the contents of the zip file on the server and open snap-setup.php file from the browser. You will see the management panel.

SNAP Universal API

Automatically post from your PHP Projects to all major social networks via one universal API interface.
Get SNAP API

Latest News/Blogposts

New Release: SNAP for WordPress Version 4

New Release: SNAP for WordPress Version 4

SNAP for WordPress Version 4 has been released. This is the biggest SNAP update ever. Almost 100% of the code was re-written. - New Autoposting Engine. Faster and 180% more efficient engine. It takes less memory and resources to preform autoposting jobs. - Old Posts...

SNAP WordPress Plugin Version 4 Beta 1

SNAP WordPress Plugin Version 4 Beta 1

The final release date for the long awaited SNAP WordPress Plugin Version 4 is set for October 1, 2017. The first closed beta version is available today. The first public beta version will be available on August 31, 2017. Here is the full release schedule: Version 4...

XING Autoposting – New NextScripts Premium API

XING Autoposting – New NextScripts Premium API

XING has recently decided to discontinue its official free API. Today we are introducing the better alternative - new NextScripts Premium API for XING. Unlike the API from XING that was able to make posts to profiles only, NextScripts Premium API for XING can post to...

New Release: SNAP for WordPress Version 3.7.10.Beta

New Release: SNAP for WordPress Version 3.7.10.Beta

UPDATE (Jan 20, 2017). Version 3.7.11 has been released to WordPress.org plugin repository. it has all code from this beta along with some fixes. Please update your plugin. ------------- New beta version is available for download. Two most popular networks Facebook...

SNAP for Wordpress

SNAP for Wordpress

SNAP for Wordpress MultiUser

SNAP for Wordpress MultiUser

SNAP API

SNAP API