The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 16, 2019, 09:37:03 PM

Login with username, password and session length


Pages: [1] 2
  Print  
Author Topic: Best way to.... content generate  (Read 5986 times)
imred
Rookie
**
Offline Offline

Posts: 26


View Profile
« on: November 14, 2007, 07:21:10 PM »

Hey guys,

   So, I am embarking on writing my first content generator in .NET.  I was hoping there might be someone who could give a bit of advice here not specifically related to .NET.

The site will basically have:

Homepage with several content sections which I will auto-generate (of course), but the main idea was adding a wordpress blog to the site to 'control' everything.  I want to auto-update the blog with my own 'article spinner' and even add 'spun' pages to the blog as well... However, I would also like the blog to ping when those new posts go online.

Is there a way to add those to Wordpress AND have them blog automatically?

My content generator will basically take 'articles' that are in my own database, spin them, and post them to Wordpress. The rest of the generator will update the content on the homepage to include the links to Wordpress pages and then change the content around on occasion.

I know this sounds a bit unthought out, but that really isn't the case.  I mainly need to be able to auto-feed WP and then I am on my way.

Thanks guys!
Logged
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #1 on: November 14, 2007, 08:36:27 PM »

i actually am in the process of the same thing

use the XMLRPC to post. its the file at yourblog.com/xmlrpc.php

it will ping when you post.

there are many discussions of xmlrpc out there, however, there do not seem to be many examples. my host doesnt have some of the XML functionality built in, so I had to go a non-standard route, but you could even just do it using perk's webrequest class. Since all you are sending is an specifically formed XML envelope to that xmlrpc.php page.

you can even assign posts to categories.

I was going to insert straight into the wordpress database, but I decided to let the existing code in wordpress do all the heavy lifting. Why should I do it when it is already there?
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
imred
Rookie
**
Offline Offline

Posts: 26


View Profile
« Reply #2 on: November 14, 2007, 09:43:02 PM »

Sounds interesting.  I was considering writing directly to the database as well.  It was either going to be email or database.

I was going to insert straight into the wordpress database, but I decided to let the existing code in wordpress do all the heavy lifting. Why should I do it when it is already there?

Do you mean using the xmlrpc.php?  Or are you talking about another method?

I will certainly do some research now and I appreciate your help.!
Logged
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #3 on: November 14, 2007, 10:14:23 PM »

yep its easy actually to do.

I had to use an alternative class to handle the code, since for some reason the default xmlrpc stuff that is built into php didnt work for me.

so try the following code without the includes. If it doesnt work, go here:
http://sourceforge.net/projects/phpxmlrpc/
and download the code. You only need the 3 classes, and actually you might only need 2 of them but i havent gotten to my refinement phase.

Code:
require_once('inc/xmlrpc.inc');
require_once('inc/xmlrpcs.inc');
require_once('inc/xmlrpc_wrappers.inc');

$c = new xmlrpc_client("/xmlrpc.php", "www.someblogofmine.com");

$content['title']="Test Post";
$content['description']="This is a <!--more-->a test post";
$content['categories'] = array("somecategory");
$content['mt_keywords'] = array("this is a tag","and another tag");
$x = new xmlrpcmsg("metaWeblog.newPost",
array(php_xmlrpc_encode("1"),
php_xmlrpc_encode("admin"),
php_xmlrpc_encode("yourpassword"),
php_xmlrpc_encode($content),
php_xmlrpc_encode("1")));

$c->return_type = 'phpvals';
$r =$c->send($x);
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: November 14, 2007, 11:32:03 PM »

Nicely done NBs... ooooh man the gears are spinning...
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
imred
Rookie
**
Offline Offline

Posts: 26


View Profile
« Reply #5 on: November 15, 2007, 06:02:55 AM »

Nicely done NBs... ooooh man the gears are spinning...

Mine just spun off their track Smiley  Thanks a ton NBs!  Now - to get to work!
Logged
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #6 on: November 15, 2007, 07:42:17 AM »

its actually not really anything new, since thats how most of the off the shelf content generators work, including the autoposters for wordpress.

HOWEVER.
if you can xmlrpc your own stuff, you can post to ANY xmlrpc capable blog that you have permissions for.
so wordpress, typepad, moveabletype,blogger, etc etc etc etc.

But the biggest reason for me is to be able to completely separate the content generation from the delivery.
Generate here - deliver anywhere.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
imred
Rookie
**
Offline Offline

Posts: 26


View Profile
« Reply #7 on: November 15, 2007, 10:00:53 PM »

So, I got to work... Smiley  I'm happy to say, I've begun communicating with one of my test blogs! 


For those .NET guys out there:  This is basic code that will allow you to post to your WORDPRESS blog.  It is VERY rudimentary, but should get any idiot (like myself) started.

FIRST:  Download XML-RPC.Net (http://www.xml-rpc.net/)
SECOND: Add the reference to the dll (CookComputing.XmlRpcV2.dll) to your VB.Net project
THIRD:  Add a simple form to your project (for the pushbutton to run the post)
FOURTH: Use the code below to write to your blog!!!!

Code:
Imports CookComputing.XmlRpc

Public Class Form1

    Public RetError As Integer
   


    <XmlRpcUrl("http://YourBlogURLGoesHere/xmlrpc.php")> _
    Public Interface IWP
        Inherits IXmlRpcProxy

        <XmlRpcMethod("blogger.newPost")> _
         Function newPost(ByVal args() As String) As Integer

    End Interface


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim proxy As IWP = XmlRpcProxyGen.Create(Of IWP)()
        Dim args() As String = {"", "", "YourUserName", "YourPassWord", "Your Content Goes Here", "publish"}

        RetError = proxy.newPost(args)

    End Sub
End Class



If you can't figure it out from that.... you might want to stop coding  ROFLMAO


Logged
Johnbert18
n00b
*
Offline Offline

Posts: 1


View Profile
« Reply #8 on: May 20, 2009, 09:14:31 PM »

              I was based my writing in season what topic is usually popped up.



_________________
<mod>holy markov batman</mod>
« Last Edit: May 20, 2009, 10:11:04 PM by nutballs » Logged

No links in signatures please
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #9 on: May 21, 2009, 06:13:10 AM »

Nothing suspicious at all about bumping a 2 year old thread.

Kids these days.  Roll Eyes
Logged

hai
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #10 on: May 21, 2009, 06:59:30 AM »

I'm glad it was bumped tho. Two years ago, I didn't know what xml was.

Now I form my own xml string and just POST it.


Code:
$xml_string =<<here;
<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
<methodName>metaWeblog.newPost</methodName>
<params>
<param>
<value><int>1</int></value>
</param>
<param>
<value><string>$user</string></value>
</param>
<param>
<value><string>$pass</string></value>
</param>
<param><value><struct>
<member><name>title</name><value><string>$title</string></value></member>
<member><name>description</name><value><string><![CDATA[$description]]></string></value></member>
<member><name>mt_allow_comments</name><value><string>0</string></value></member>
<member><name>mt_allow_pings</name><value><string>0</string></value></member>
<member><name>mt_keywords</name><value><array><data>$tag_data</data></array></value></member>

</struct></value></param>
<param>
<value><int>1</int></value>
</param>
</params>
</methodCall>
here

The "here"s just allow a multi line string in perl.  So, if you put a string like that together
(with each post, so that the variables can be varied), you can just sent it with a normal
POST.

Well, you have to set the content type which in perl we do like this:

$req->content_type('text/xml');

I guess it all boils down to the same tho.  I just wanted to post some code somewhere. Cheesy

Bompa



Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #11 on: May 21, 2009, 08:44:16 AM »

Nice Bomps.

And just for anyone watching, the here; equivalent in PHP is called HEREDOC format and it looks like this:

$aStr = <<<ANYWORD
This is a test of the emergency broadcasting system.
If this had been an actual test, you would have been informed
as to where to tune in your area for news and information.
ANYWORD;

Note that ANYWORD can literally be any word at all, provided it is identical at the beginning and end, and the closing one is not indented and followed by a semicolon.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #12 on: May 21, 2009, 08:55:51 AM »

I use heredocs ALL THE TIME when working with javascript.

Precious little js on my sites is static.
Logged

hai
isthisthingon
Global Moderator
Lifer
*****
Offline Offline

Posts: 2879



View Profile
« Reply #13 on: May 21, 2009, 09:43:16 AM »

Quote
This is a test of the emergency broadcasting system.
If this had been an actual test,

I love it.  It's almost impossible for us dyslexics to realize that this was an actual "test"  Grin
Logged

I would love to change the world, but they won't give me the source code.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #14 on: May 21, 2009, 02:25:37 PM »

I use heredocs ALL THE TIME when working with javascript.

Precious little js on my sites is static.

i use it all over the place as well, especially since all my sites are dynamic - all the large chunks of HTML are HEREDOC as well. It is handy, that with rev 5 of PHP they cleared out some of the speed issues that existed with 4 and below. Apparently, some of the crap-code that I've looked through (that is just lousy with ugly concatenations) is because concats were way faster than either interpolation or HERDOC. Now they're just about the same, which is great because HEREDOC is such an easier read.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1] 2
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!