Add crosspost functionality for other blogs such as MySpace and Wordpress.
| Project: | LiveJournal CrossPoster |
| Version: | 5.x-1.x-dev |
| Component: | User interface |
| Category: | feature request |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Thanks for the great module. It works perfectly with my 5.1 installation, and very seamlessly posts any content I select to my LiveJournal. It even posts Leech RSS feeds quite well, so overall a very impressive module. I was wondering if you have plans to add functionality for other blogs in the future. I am personally interested in MySpace, but I am sure there are others out there who would like to see other blogs added as well. I have two references for you if you are interested.
One is a crosspost hack lithboy has made for Wordpress and MySpace. The second is the source of my MySpace blog post page. I would be willing to assist with a little guidance. I have attached the cfm file to this post. Rename it from png or just open it in a text editor. The following text denotes the hack by lithboy:
1. f using wordpress 1.2+, turn on legacy hacks file support in options->misc
2. add the following code to your my-hacks.php file (you also have to have the hacks file enabled).
function msautoupdate ($content='’, $post_title='’) {
$tmp_cookie_file=tempnam(”/tmp”, “msautoupdate_cookie”);
$ms_userid = “you@example.com”; //Your myspace email, please replace within quotes
$ms_passwd = “f00bar”; //Your myspace password, please replace within quotes
$real_blog_url = “http://your.wordpress.com/blog”; //Change this to your blog’s address
if($post_title==”") { $post_title = “(no subject)”; }
$content = stripslashes(stripslashes($content));
$content = convert_smilies($content);
$content = convert_chars($content, ‘html’);
$content .= “
NOTE: this blog is only a ghost (copy) of my real blog. if you want to see the real thing (or to post your comments), you need to go heren”;
$content = urlencode($content);
$event = $content;
$subject = stripslashes(stripslashes($post_title));
$year = date(’Y', time());
$month = date(’m', time());
$day = date(’d', time());
$hour = date(’H', time());
$minute = date(’i', time());
$marker = date(’A', time());
$defined_vars = get_defined_vars();
$login_url = ‘http://blog.myspace.com/index.cfm?fuseaction=login.process’;
$login_params = “email=$ms_userid&password=$ms_passwd&Remember=0″;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $login_url);
curl_setopt($ch, CURLOPT_POSTFIELDS,$login_params);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars[’HTTP_USER_AGENT’]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $tmp_cookie_file);
$result=curl_exec ($ch);
curl_close ($ch);
$post_url = ‘http://blog.myspace.com/index.cfm?fuseaction=blog.processCreate’;
$post_params = “postMonth=$month&postDay=$day&postYear=$year&postHour=$hour&postMinute=$minute&postTimeMarker=$marker&subject=$subject&body=$content”;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_params);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_USERAGENT, $defined_vars[’HTTP_USER_AGENT’]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, $tmp_cookie_file);
$result=curl_exec ($ch);
curl_close ($ch);
unlink($tmp_cookie_file);
//echo(”Output: “.$result);
}
3. change the email, password, and real blog url lines in the file above to that of your myspace account and the location of your wordpress site.
4. Then find post.php inside your wp-admin folder and find:
case 'post':
and then look for this line:
$result = $wpdb->query($postquery);
paste the following code right after that line:
if ($content && $post_status == 'publish') msautoupdate($content, $post_title);
to add a ‘update myspace’ checkbox to the post screen
1. Find this line in your edit-form.php file (which is inside the wp-admin folder):
Add this right below that(BEFORE the ):
Update Myspace
2. in in your edit-form-advanced.php:
Add this right below that (BEFORE the ):
Update Myspace
3. just added in post.php (in your wp-admin folder):
if ($content && $post_status == 'publish') msautoupdate($content, $post_title);
And replace it with:
$msautoupdate = $HTTP_POST_VARS['msautoupdate'];
if ($content && $post_status == 'publish' && $msautoupdate) msautoupdate($content, $post_title);
| Attachment | Size |
|---|---|
| myspaceblog.cfm_.png | 36.61 KB |

#1
I didn't have any plans to do such myself as I don't actually use either of those services; and it might be better if such a thing were its own module, to keep the interface from getting too overdone. I can see where such a thing might be valuable, however. Alas, I haven't really got the time to do much with that. I could cheer from the sidelines and happily tell you to take the ljxp module, take out the parts that won't work for myspace/wordpress and retool it, but I'm not sure I'm able to offer any real guidance doing that. I can try to answer if you have specific questions.
There is another module, the 'blogclient' module which might be able to do what you want. It's more generic, and so might be harder to use (the main reason for this module to even exist over blogclient is sheer ease of use). I haven't tried it myself.
#2
Is it now possible to post the content of a story right on a myspace blog?
Think this is code for WordPress. Would be very nice if you could cross-post.
Maybe it's possible to do it with a cronjob. Does anyone know something about?
Thx,
Philipp
#3
Thanks merlinofchaos. I will take yer invite and try to dev the MySpace as a separate module using your code as a base. Agent-orange, that code is for WordPress, but it will serve as a good example of what needs to be done to get Drupal to crosspost to MySpace. It would work the same way that LJXP works, crossposting at the time of page creation. No cron jobs necessary. Merlinofchaos, I may indeed tap your brain occassionally for advice when I get stuck, but I will try to do all the heavy lifting. I still think It should be one module, as I feel there are already too many instances of modules out there that do relatively the same thing. (WYSIWYG, audio modules, polls) I think it just gums up the projects to have so many similar modules out there. Either way, I am still interested enough in this to try and develop it on my own, so thanks for the challenge. I will first however check out blogclient module. Thanks again for the great module for Livejournal crossposting.
#4
I'm curious about a myspace option...has anyone started any development in this direction? (I.e. a myspace crossposter)