Quick Fix for Xanga Crosspost 0.1 Login Issue

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

  1. Posted November 27, 2006 at 8:28 am | Permalink

    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.

  2. Posted November 27, 2006 at 8:50 am | Permalink

    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.

  3. Posted November 27, 2006 at 10:13 am | Permalink

    Thanks so much for the files, they work beautifully!!!

  4. Berwick
    Posted November 29, 2006 at 10:31 am | Permalink

    would you mind to send me one also, i can’t get this work….
    thx

  5. Posted November 29, 2006 at 11:23 am | Permalink

    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.

  6. Posted November 29, 2006 at 7:13 pm | Permalink

    Zip posted -> see link above.

  7. Posted December 12, 2006 at 8:25 am | Permalink

    genius. thanks.

  8. Posted February 2, 2007 at 9:45 am | Permalink

    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

  9. Posted February 10, 2007 at 5:08 pm | Permalink

    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!

  10. Posted April 17, 2007 at 11:27 pm | Permalink

    Thank You

  11. Posted May 1, 2007 at 9:59 pm | Permalink

    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

  12. Posted May 1, 2007 at 10:32 pm | Permalink

    And I tries to use 0.4 version + manual edition using this page.
    Result is “Error: Invalid username or password.”

  13. Posted May 2, 2007 at 8:40 am | Permalink

    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?

  14. Posted May 2, 2007 at 8:56 pm | Permalink

    Yes. I tried to use only 0.4 too.

  15. Posted May 2, 2007 at 9:42 pm | Permalink

    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.

  16. Posted May 2, 2007 at 10:06 pm | Permalink

    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

  17. Posted May 17, 2007 at 10:15 am | Permalink

    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.

  18. Posted May 25, 2007 at 4:50 pm | Permalink

    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?

  19. Posted May 28, 2007 at 11:55 am | Permalink

    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

  20. Posted May 28, 2007 at 11:58 am | Permalink

    As a matter of fact, I did try his latest plugin, the same day I posted my comment. :)

  21. Posted May 28, 2007 at 12:12 pm | Permalink

    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.

  22. Posted May 28, 2007 at 12:16 pm | Permalink

    Alrighty! Thanks :)

  23. Posted May 28, 2007 at 8:39 pm | Permalink

    Login is OK :)
    Thank you

  24. Posted June 2, 2007 at 2:48 am | Permalink

    good work…

  25. Posted September 20, 2008 at 1:14 am | Permalink

    evista windows evista lcars

One Trackback

  1. [...] 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? [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*