- Make sure that your web domain has libcurl feature. Check you server info whether there is cURL Information: libcurl OpenSSL. If you are using webhosting server, ask the webhosting provider, whether there is a libcurl feature or not. This feature is very important, otherwise, your Facebook Share will not work, and will display message like this: \"Protocol https not supported or disabled in libcurl\"...
- Make sure that Social Networks Feature (under the Admin Menu - Admin Home - Preferences) is enabled.
- Make sure that user permission for tiki_p_socialnetworks (under the Admin Menu - User Permissions - Social Networks) is enabled.
- Activate first your Facebook integration with TikiWiki by opening /tiki-socialnetworks.php. Facebook will give you an Access Token to automatically post a message to your Facebook Wall. This Access Token is stored in the table tiki_user_preferences.
- After all the above requirements finished, open file /lib/articles/artlib.php. Add this function below://Function to call social network, begin
function postToSocialNetwork($user, $articleId, $objectTitle, $body){
global $socialnetworkslib, $smarty, $prefs, $tikilib;
$foo = parse_url($_SERVER["REQUEST_URI"]);
$parts = explode('/', $foo['path']);
if (count($parts) > 1) unset ($parts[count($parts) - 1]);
$mail_machine_raw = $tikilib->httpPrefix( true ). implode('/', $parts) . '/';
include_once('tiki-sefurl.php');
$urlFB= $mail_machine_raw . filter_out_sefurl('tiki-read_article.php?articleId=' . $articleId, $smarty, 'article', $objectTitle);
include_once ('lib/socialnetworkslib.php');
//post to facebook wall
$userPostToFacebookWall = $tikilib->get_user_preference($user, 'facebook_token', '');
if (!empty($userPostToFacebookWall)) {
$socialnetworkslib->facebookWallPublish($user, $body, $urlFB,'',$urlFB,'');
}
//Function to call social network, end - Now, search these scripts below:$nots = $tikilib->get_event_watches('article_submitted', '*');If you are using this TikiWiki version and original/unmodified artlib.php, the above scripts started on line 520. Right below those scripts (line 524), insert the call function of postToSocialNetwork like this:
$nots2 = $tikilib->get_event_watches('topic_article_created', $topicId);
$smarty->assign('mail_action', 'New');
}$this ->postToSocialNetwork($author,$articleId,$title,$heading); - Save and close /lib/artlib.php
- Finish. You can start writing an article and when it has been approved, you article should have been posted to your Facebook Wall.
Tuesday, July 26, 2011
Customizing Facebook Share on TikiWiki
One of the advantages of using TikiWiki is its Social Networks feature, i.e. the Facebook Share that we have already known so far this day. Under this feature, we can share automatically any article, blog posting, forum, or comment. TikiWiki has provided the Facebook Share Open Graph protocol as required by Facebook Developer. Following tip will guide you on applying Facebook Share. We use article object as the example.
Subscribe to:
Post Comments (Atom)
This post is really helpful to me. I am searching for this type of post from long time. Thanks for sharing.
ReplyDeleteDanielle
customize facebook page