How to post to Facebook
1. Post using class
<?php
// First, let's get settings.
$fileData = file_get_contents(dirname(__FILE__).'/nx-snap-settings.txt');
$snapOptions = maybe_unserialize($fileData);
//### Set to post only to the first Facebook account
$postOnlyTo = array('fb'=>array(0));
if (class_exists("cl_nxsAutoPostToSN")) {
// Initialize the class
$nxsAutoPostToSN = new cl_nxsAutoPostToSN($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 directly without class.
You will need $message and $options arrays described here: http://www.nextscripts.com/snap-api/docs/
<?php
require_once "nxs-functions.php";
require_once "inc-cl/fb.api.php";
$message = array(
'text'=>'Social Networks Auto Poster (SNAP) API is
a universal API for the most popular social networks',
);
$options = array(
'fbURL'=>'https://www.facebook.com/nextscripts',
'pgID'=>'nextscripts',
'fbAppPageAuthToken'=>'CAAGgkQ2EVwz****************************...',
'fbAppID'=>'4580**************',
'fbAppSec'=>'425735c****************************',
'postType'=>'T',
'fbMsgFormat'=>'%TEXT%',
);
$ntToPost = new nxs_class_SNAP_FB();
$ret = $ntToPost->doPostToNT($options, $message);
if (is_array($ret) && $ret['isPosted']=='1') { // ## All Good
echo '<a target="_blank" href="'.$ret['postURL'].'">New Post</a>';
} else { // ## Error
echo "<pre>".print_r($ret, true)."</pre>";
}
?>


