PDA

View Full Version : About RSS Poster Hooks


omerfarukak
01-28-2012, 10:03 PM
Hi i want to write a plugin which is adds my wordpress posts a link which is rss posted on forum. And now i'm using rssfeeddata_postsave hook but how can i take new forum posts link? :)

kh99
01-28-2012, 10:24 PM
I can't quite follow what it is you want to do, but are you sure rssfeeddata_postsave if the right hook? It looks like that hook is called when you add an rss feed in the adminCP ("post" in this case means after it's saved and doesn't refer to posted messages).

omerfarukak
01-28-2012, 10:41 PM
I can't quite follow what it is you want to do, but are you sure rssfeeddata_postsave if the right hook? It looks like that hook is called when you add an rss feed in the adminCP ("post" in this case means after it's saved and doesn't refer to posted messages).

so, which hook i can use?

kh99
01-28-2012, 11:01 PM
Well, like I mentioned, I don't really understand what you want to do. It kind of sounds like you might need more than one plugin.

omerfarukak
01-28-2012, 11:25 PM
Well, like I mentioned, I don't really understand what you want to do. It kind of sounds like you might need more than one plugin.

Well, i'm trying again to explain. :) I'm using rss poster in vBulletin, it's getting data from my wordpress's rss feed. And opens a thread for each one. And i want to add this thread's link to end of my wordpress posts'. Is it sufficently clear? :)

kh99
01-28-2012, 11:53 PM
OK - there are no hooks in the rss poster code, but you might be able to use threadfpdata_postsave. That gets called every time a thread is created so you have to check something to make sure it's one of your wordpress threads. I think the feed url might be available using something like:

global $feed;

if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{
// add your link
}

omerfarukak
01-29-2012, 07:13 AM
What about the rssposter_parse_rss? Is there any guide about hooks?

--------------- Added 1327827918 at 1327827918 ---------------

Is this code works? Or what i have to do?
global $feed;

if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{ if (!empty($threadinfo['item_id'])) {
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
mysql_connect('localhost', 'root', '');
mysql_select_db('_wp');
mysql_query("update wp_posts set post_content=concat(post_content,'</ br></ br></ br> {feed:title}<a href=\"{feed:link}\"> {feed:title} </a>') where post_title = '{feed:title}'");
mysql_close();
}

kh99
01-29-2012, 12:42 PM
What about the rssposter_parse_rss? Is there any guide about hooks?

You're right, I missed that. You might be able to do something in rssposter_parse_rss. But the problem may be that you don't have the threadid yet so I'm not sure how you'd create a link.

I don't know of any guide to hooks, but there could be one. I just look at the php code to see where they are.


Is this code works? Or what i have to do?
global $feed;

if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{ if (!empty($threadinfo['item_id'])) {
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
mysql_connect('localhost', 'root', '');
mysql_select_db('_wp');
mysql_query("update wp_posts set post_content=concat(post_content,'</ br></ br></ br> {feed:title}<a href=\"{feed:link}\"> {feed:title} </a>') where post_title = '{feed:title}'");
mysql_close();
}

I'm not sure - I don't see how {feed:title} or {feed:link} will be substituted for the actual values. If you're trying to link back to the vb thread that gets created, then I think you'd want to do something like:


if (is_array($feed) AND strncmp($feed['url'], 'something', len) == 0)
{
$title = $this->thread['title'];
$link = '</ br></ br></ br> <a href="' . $this->registry->options['bburl'] . '/showthread.php?t=' . $this->thread['threadid'] . '">' . htmlentities($title) . '</a>';

mysql_connect('localhost', 'root', '');
mysql_select_db('_wp');
mysql_query("update wp_posts set post_content=concat(post_content,'" . mysql_real_escape_string($link) . "') where post_title = '" . mysql_real_escape_string($title) . "'");
mysql_close();
}


Also, you need to replace 'something' and 'len' in the above if statement to be something that would check to see if the feed url is the url of your wordpress feed.

omerfarukak
01-30-2012, 06:03 PM
ini_set('display_errors', 1);
if(!$link = mysql_connect('localhost', 'root', ''))
echo fails_connection;
mysql_set_charset('utf8',$link);
if(!mysql_select_db('_wp', $link))
echo fails_selection;
$link2 = '<a href="http://bburl.co/showthread.php?t=threadid">link</a>';
mysql_query("update wp_posts set post_content = concat(post_content,". mysql_real_escape_string($link2) .") where id = 1794");
echo mysql_error();
mysql_close();


When i try something like this, i get this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '<a href=\"http://bburl.co/showthread.php?t=threadid\">link</a>) where id = 1794' at line 1

What can we do?

kh99
01-30-2012, 06:54 PM
Oh, I think the mysql line is missing quotes around the link string. So something like:

mysql_query("update wp_posts set post_content = concat(post_content,'". mysql_real_escape_string($link2) ."') where id = 1794");


(I fixed it above as well).

omerfarukak
01-30-2012, 08:13 PM
Oh, I think the mysql line is missing quotes around the link string. So something like:

mysql_query("update wp_posts set post_content = concat(post_content,'". mysql_real_escape_string($link2) ."') where id = 1794");


(I fixed it above as well).

Heah now it works but when i try to match them with their title it not works because we have Turkish characters and they not matches when we take it from vbulletin... What can i do?

kh99
01-30-2012, 08:57 PM
I really don't know much about that. Are you using htmlentities() like i put in the code I originally posted? If so you could try taking that out. I think you really should have it in case the title contains any html, but maybe it's causing the problem. Other than that I really don't know.

omerfarukak
02-02-2012, 01:05 PM
Ok, have you any idea about how can i take wordpress posts' link from rss?