Pinterest the link on wordpress gives an error


I am trying to add a pinterest link to my wordpress site. Here on stackoverflow I found the following code:

    /*Stuff for Pinterest*/
    //getting the permalink
    $postpermalink = urlencode( get_permalink() );
    //getting the thumbnail
    $imageurl = urlencode( wp_get_attachment_url( get_post_thumbnail_id($post->ID) ) );
    /*End of Pinterest*/
<a target="blank" href="<?php echo $postpermalink ?>&media=<?php echo $imageurl ?>" title="Pin This Post">pinterest</a>

But when I test it, pinterest gives me the following error:

Whoops! Parameter 'method' (value link) is not one of unknown, uploaded, scraped, bookmarklet, email, iphone, button, ipad, android, android_tablet, api_sdk, extension, api_other, bad.

I've tried tons of different links, but without success. Any ideas?

According to this resource at pinterest, you'll need to include the pinit.js javascript link somewhere in the page or otherwise the pin-it link will not work (I ran into this very same problem today):

The downside of doing it this way is that if you had any custom graphics or text inside your link, those will be overwritten by the javascript code, and I can't find a way to override this behavior at this time. I'm bookmarking this page in the hopes that someone found or will find some magic way to override the pinterest override.