Chào các bạn. đây là bài viết hướng dẫn tạo bài viết tức thời trên facebook.
- 1. Nếu ai chưa biết thì nên hỏi bác google
- 2. Nếu đã biết rồi thì bắt đầu làm:
+ Đầu tiên: cần có 1 fanpage kiểu tin tức, blog, ... và có ít nhất 5 bài viết
+ Sau đó , các bạn chọn tabs Công cụ đăng, tiếp đó, dưới góc trái có mục bài viết tức thời, chọn cấu hình
Bạn cần phải cấu hình rss để facebook nhận link tự động thông qua rss.
bạn chỉ cần để ý 2 mục : nguồn cấp rss sản xuất và nguồn cấp rss phát triển.
điền link rss vào đó và nhấn lưu lại.
thường link rss sẽ có dạng : http://domain.com/rss/tin-tuc/
facebook sẽ có những quy định bài viết nên các bạn xem kỹ và làm theo :
+ trong bài viết , tối thiểu phải có 1 hình ảnh.
+ link hình ảnh không được nằm trong thẻ <p>
+ link hình ảnh bắt buộc phải nằm trong thẻ figure, vd:
<figure data-feedback="fb:likes, fb:comments"><img src=""></figure>
+ nội dung trong thẻ không được để trống , ví dụ : <div></div>, <p></p> ....
- Nếu xử lý hết các lỗi trên, các bạn có thể tiến hành gửi xét duyệt trong bước 2, mục cấu hình của facebook. thông thường facebook sẽ duyệt trong 1-2 ngày. nếu xét duyệt thành công sẽ dc chuyển qua bước 3. qua được bước 2 là ngon lành rồi.
Bạn cần thay thế 2 file sau :
1 - /modules/news/func/rss.php
<?php /** * @Project NUKEVIET 4.x * @Author VINADES (contact@vinades.vn) * @Copyright (C) 2014 VINADES. All rights reserved * @License GNU/GPL version 2 or any later version * @Createdate Apr 20, 2010 10:47:41 AM */ if (! defined('NV_IS_MOD_NEWS')) { die('Stop!!!'); } $channel = array(); $items = array(); $channel['title'] = $module_info['custom_title']; $channel['link'] = NV_MY_DOMAIN . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name; $channel['description'] = ! empty($module_info['description']) ? $module_info['description'] : $global_config['site_description']; $catid = 0; if (isset($array_op[1])) { $alias_cat_url = $array_op[1]; $cattitle = ''; foreach ($global_array_cat as $catid_i => $array_cat_i) { if ($alias_cat_url == $array_cat_i['alias']) { $catid = $catid_i; break; } } } function getBaseUrl() { // output: /myproject/index.php $currentPath = $_SERVER['PHP_SELF']; // output: Array ( [dirname] => /myproject [basename] => index.php [extension] => php [filename] => index ) $pathInfo = pathinfo($currentPath); // output: localhost $hostName = $_SERVER['HTTP_HOST']; // output: http:// $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://'; // return: http://localhost/myproject/ return $protocol.$hostName.$pathInfo['dirname'].""; } function vndes_body($id) { global $db, $module_data, $module_name; $sql = "SELECT bodyhtml FROM " . NV_PREFIXLANG . "_" . $module_data . "_bodyhtml_" . ceil( $id / 2000 ) . " WHERE id =" . $id; $result = $db->query( $sql ); $row = $result->fetch(); // $row['bodyhtml'] = strip_tags( $row['bodyhtml'],'<img>'); $bodytext = preg_replace( '/(\s)+(id|class|style|alt)="(.*)"(\s)*/U', ' ', $row['bodyhtml'] ); $bodytext = preg_replace('/<img\s+src="([^"]+)"[^>]+>/i', '</p><figure data-feedback="fb:likes, fb:comments"><img src="$1" /></figure><p>', $bodytext); // $bodytext=str_replace(array("'",'&','>','<','"'),array(''','&','>','<','"'),$bodytext); //$bodytext1 =str_replace("/<p>(.*?)<\/p>/", "$1",$bodytext); $bodytext = str_replace(array('<div>', '</div>','<p >','<div >','<p><p>','</p></p>', '<p align="center"></p>','<p></p>','<br>','<span >'), array('', '','<p>','','<p>','</p>','','','','<span>'), $bodytext); return str_replace( '/uploads/', getBaseUrl() .'uploads/',$bodytext); } $db_slave->sqlreset() ->select('id, catid, publtime, title, alias, hometext, homeimgthumb, homeimgfile') ->order('publtime DESC') ->limit(30); if (! empty($catid)) { $channel['title'] = $module_info['custom_title'] . ' - ' . $global_array_cat[$catid]['title']; $channel['link'] = NV_MY_DOMAIN . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $alias_cat_url; $channel['description'] = $global_array_cat[$catid]['description']; $db_slave->from(NV_PREFIXLANG . '_' . $module_data . '_' . $catid) ->where('status=1'); } else { $db_slave->from(NV_PREFIXLANG . '_' . $module_data . '_rows') ->where('status=1 AND inhome=1'); } if ($module_info['rss']) { $result = $db_slave->query($db_slave->sql()); while (list($id, $catid_i, $publtime, $title, $alias, $hometext, $homeimgthumb, $homeimgfile) = $result->fetch(3)) { $catalias = $global_array_cat[$catid_i]['alias']; if ($homeimgthumb == 1) { // image thumb $rimages = NV_BASE_SITEURL . NV_FILES_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 2) { // image file $rimages = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/' . $module_upload . '/' . $homeimgfile; } elseif ($homeimgthumb == 3) { // image url $rimages = $homeimgfile; } else { // no image $rimages = ''; } $rimages = (! empty($rimages)) ? '<img src="' . $rimages . '" width="100" align="left" border="0">' : ''; $items[] = array( 'title' => $title, 'link' => NV_MY_DOMAIN . NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $catalias . '/' . $alias . '-' . $id . $global_config['rewrite_exturl'], // 'guid' => $module_name . '_' . $id, // 'description' => $rimages . $hometext, // 'hometext' => $hometext, 'bodytext' => vndes_body($id), 'pubdate' => $publtime, 'time' => date('Y-m-d', $publtime )// ); } } nv_rss_generate($channel, $items); die();
2 - /themes/default/layout/rss.tpl
<!-- BEGIN: main --><?xml version="1.0" encoding="utf-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>{CHANNEL.title}</title> <link>{CHANNEL.link}</link> <atom:link href="{CHANNEL.atomlink}" rel="self" type="application/rss+xml" /> <!-- BEGIN: description --><description><![CDATA[{CHANNEL.description}]]></description><!-- END: description --> <language>{CHANNEL.lang}</language> <!-- BEGIN: pubDate --><pubDate>{CHANNEL.pubDate}</pubDate> <lastBuildDate>{CHANNEL.pubDate}</lastBuildDate><!-- END: pubDate --> <copyright><![CDATA[{CHANNEL.copyright}]]></copyright> <docs>{CHANNEL.docs}</docs> <generator><![CDATA[{CHANNEL.generator}]]></generator> <!-- BEGIN: image --> <image> <url>{IMAGE.src}</url> <title>{IMAGE.title}</title> <link>{IMAGE.link}</link> <width>{IMAGE.width}</width> <height>{IMAGE.height}</height> </image> <!-- END: image --><!-- BEGIN: item --> <item> <title>{ITEM.title}</title> <link>{ITEM.link}</link> <guid>{ITEM.link}</guid> <description><![CDATA[ {ITEM.description} ]]></description> <!-- BEGIN: pubdate --><pubDate>{ITEM.pubdate}</pubDate><!-- END: pubdate --> <content:encoded> <![CDATA[ {ITEM.bodytext} <figure class="op-ad"> <iframe width="300" height="250" scrolling="no" frameborder="0" style="border:0; margin:0;" src="https://www.facebook.com/adnw_request?placement=1608936029424517_1681354882182631&adtype=banner300x250"></iframe> </figure> ]]> </content:encoded> </item> <!-- END: item --> </channel> </rss> <!-- END: main -->
Ai không hiểu cứ việc hỏi trên đây hoặc trên fb : fb.me/quocdoan419
thế nhé