Joe Tan has released a number of WordPress plugins available on his site. At present I use a couple of them: the Google Analytics & Feedburner Report and the Flickr Photo Album plugins.
Update: Joe’s latest release has fixed this particular issue. It looks like users might be experiencing a similar problem with ver 0.5 but I am unable to reproduce the error. Keep an eye on Joe’s page for another fix.
It was while browsing these tools that I came across his Xanga Crosspost for Wordpress plugin. I had no idea what Xanga even was or what this plugin did but upon viewing Joe’s Xanga page it became immediately obvious to me how useful the plugin might be. If nothing else perhaps it could leave a crumb trail for increased traffic.
Trouble with Xanga
After downloading and installing the plugin (which was effortless I might add). I then opened the Plugin configuration page to link my Xanga account with my Wordpress installation.
However when I submitted my Xanga username and password I received an “Error: Invalid username or password”. After retyping this several times and then copying and pasting the same credentials I used on Xanga’s site directly it became obvious to me that the problem was not my username or password.
After checking back in at the plugin homepage I noticed 4 recent comments describing the same problem. Something must have changed on Xanga’s end of things. But according to his site, Joe’s out of town for the holidays… if I want this working today it looks like I’ll have to hack it.
After playing around a bit with the code it became clear that the problem is most likely due to Xanga moving the “Set-Cookie” information to an unusual place. Anyway… below is a fix for the plugin.
Update lib.xanga.php
The default installation for this file is in <your plugins directory>\tantan\xanga\lib.xanga.php
Go ahead and replace the 2nd instance of the following (line 82ish):
$this->cookies = $this->req->getResponseCookies();
With this:
$this->cookies = $this->req->getResponseCookies('body');
Note: Only change the 2nd instance of the above code; leave the first instance of “$this->cookies = $this->req->getResponseCookies();” untouched.
Update curl.php
When I installed the Xanga Crosspost plugin, my <plugins directory>\tantan\lib\curl.php was replaced with another version. After comparing the two it appears that the version which came with the plugin is actually older than the one it replaced. No worries, they both didn’t work and the only difference between the two is the getResponseCookies() function - which we are about to append.
Replace the entire getResponseCookies() function with this:
// Indenting reduced for blog readability
function getResponseCookies($header='header') {
$hdrCookies = array();
if ($header == 'header') {
foreach ($this->response[$header] as
$key => $value) {
if (strtolower($key) == ’set-cookie’) {
$hdrCookies = array_merge($hdrCookies,
explode(”\n”, $value));
}
}
}elseif($header == ‘body’) {
$hdrTemp = array();
$hdrTemp =
explode(”\n”, ((string)$this->response['body']));
foreach ($hdrTemp as $val) {
list($name, $value) = split(”:”, $val);
if (strtolower($name) == ’set-cookie’) {
$hdrCookies[] =
str_replace(”Set-Cookie: “, “”, $val);
}
}
}
$cookies = array();
foreach ($hdrCookies as $cookie) {
if ($cookie) {
list($name, $value) = explode(’=', $cookie, 2);
list($value, $domain, $path, $expires) =
explode(’;', $value);
$cookies[$name] =
array(’name’ => $name, ‘value’ => $value);
}
}
return $cookies;
}
That’s it - worked for me and it shouldn’t mess up any other tan-tan plugins that use the same library. Post any questions regarding this fix in the comments and I’ll be happy to address them.
Thanks again to Joe for his great plugin - be sure to view his other tools as well.
(Joe - if you’d like any more information on this issue for a future release please contact me.)
Additional Resources
25 Comments
I think I did all that you said, but I still can’t get it to work. I found 2 places that had “$this->cookies = $this->req->getResponseCookies();
“, so I’m not sure which line to replace with the new one. is there anyway you can email me both files with the changes so I can upload them to my site, or clairify for idiots like me?:) thank you so much foryour time.
Sure thing, files emailed.
If this helps anyone else, I should clarify that it is the second instance of “$this->cookies = $this->req->getResponseCookies();” that should be replaced. I’ll update the post and try to make that more clear.
Thanks so much for the files, they work beautifully!!!
would you mind to send me one also, i can’t get this work….
thx
Hmm.. sounds like there must be a typo or such in the post. I’ll add a downloadable zip in the next few days. In the meantime Berwick, I’ve emailed you the files.
Zip posted -> see link above.
genius. thanks.
So I’m finally getting around to updating the plugin, thanks for investigating this issue
I’m still not exactly sure what is going on, but I’ll checkin your patch and post an update sometime soon.
Thanks again!
Joe
Hello, my name is Alex, i’m a newbie here. I really do like your resource and really interested in things you discuss here, also would like to enter your community, hope it is possible:-) Cya around, best regards, Alex!
Thank You
Hello,
I try to setup your plugin on WP 2.1, but when I login I get “Error: Invalid username or password.”
I use 0.4 version and fix “xanga1_0_fix”.
Could you help me?
Thank you
And I tries to use 0.4 version + manual edition using this page.
Result is “Error: Invalid username or password.”
Hi Andrey, Joe mentioned to me that he fixed this issue entirely with his latest release (0.4). This might be an obvious question but have you tried using that version without the fix installed?
Yes. I tried to use only 0.4 too.
I’m afraid I can’t be of much help as this must be some sort of new error. If you haven’t already tried and your Xanga account is a new one you might need to check the ‘Premium Account’ check box in the cross-post options page.
Sorry I can’t be of more help.
Not. Changing to Premium Account didn’t help.
Does anybody help me and try to crosspost to my Xanga account? Please, write to admin@ms-dynamics.ru
Thank you
Argh! I can’t get it to work either. I’ve tried 3 plugins and 3 times I’ve struck out.
I think I’m having the same problem as Andrey.
I tried doing your instructions, but they didn’t work so I downloaded your zip file. Unfortunately, it removed the checkbox (giving the option to crosspost or not) from my Write Post page. Is it possible to get that back?
Hi Anne, have you tried tantan’s latest version of the plugin? My hack was made to an older version that doesn’t appear to have supported the checkbox that you are referring to. Good Luck - Jason
As a matter of fact, I did try his latest plugin, the same day I posted my comment.
Hmmm sorry to hear that hasn’t worked out for you… Joe is a pretty hard guy to get a hold of but it looks like he said he’s going to look into the issue (you already knew that I’m sure). I’ll post a message here so users will know to keep an eye out for his update.
Alrighty! Thanks
Login is OK
Thank you
good work…
evista windows evista lcars
One Trackback
[...] After months figuring out why Ryan’s Croissanga pluing isn’t working on my site, I’ve installed the Xanga Crossposting Plugin from Tan Tan Noodles and hope it’ll work. For users who are interested, please note some of you might experience error messages like “Error:Invalid username and password” when you activate it in the options panel. In this case, get the patch at Jason Robert’s page. Ryan Lee’s website is no longer working. What a sad thing that such a great blogger has left the blogsphere, anyone knows where he moved? [...]