title: Pinterest button - invalid url
body: <p>Since yesterday when Pinterest updated its website, my Pinterest 'Pin it' buttons stopped functioning properly, i.e. the spinning wheel goes forever in the popup window.</p>
  
  <p>My code - which used to work fine - is:</p>
  
  <pre><code>    &lt;a data-pin-config="beside" href="//pinterest.com/pin/create/button/?url=&lt;?=urlencode($url)?&gt;&amp;media=&lt;?=urlencode($image_url) ?&gt;&amp;description=The picture I just pinned!" data-pin-do="buttonPin" &gt;
       &lt;img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" /&gt;
      &lt;/a&gt;                    
  </code></pre>
  
  <p>I also include the Pinterest js just before the <code>&lt;/body&gt;</code> closing tag.</p>
  
  <p>What is interesting is that when I go on Pinterest's website and try to <code>Add Pin</code> by URL, I get: </p>
  
  <blockquote>
    <p>"Whoops! Invalid URL"</p>
  </blockquote>
  
  <p>My $url refers to php pages which pass several parameters, i.e. 
  <code>http://www.mywebsite.com/img.php?img_id=photo (999).jpg&amp;album=...&amp;page=...</code></p>
  
  <p><strong>Update #1:</strong> I noticed that when the posted URL does not contain any parentheses, there is no problem posting on Pinterest directly or via the buttons. Although the URLs are all urlencoded in php, i.e. the ( and ) are encoded to %28 and %29 respectively, which should be taking care of the parentheses, it does not seem to work. The browser still shows the parentheses although I realize that it is interpreting the url encoded %28 and %29 codes.</p>
  
  <p><strong>Update #2:</strong> Received reply from Pinterest saying</p>
  
  <p>"<em>Sometimes we see this behavior if a website is blocking Amazon IPs. 
  Make sure you're not blocking Amazon IPs or whitelist our user agent:</em></p>
  
  <blockquote>
    <p>Pinterest/0.1 +<a href="http://pinterest.com/" rel="nofollow">http://pinterest.com/</a></p>
  </blockquote>
  
  <p><em>Unfortunately, we don't have a dedicated group of IPs that you could whitelist because our IPs change over time.</em>"</p>
  
  <p>Following Pinterest's reply, I did my research and came up with the following relevant links:</p>
  
  <ul>
  <li><p><a href="http://wordpress.org/support/topic/note-when-entering-user-agent-whitelist" rel="nofollow">http://wordpress.org/support/topic/note-when-entering-user-agent-whitelist</a></p>
  
  <p>"<em>Pinterest have to be whitelisted as a referrer or agent so that it will see the image - if not it will just see the redirect to a HTML page (thus "not a valid image").
  Try to put pinterest and pinterest.com on your user agent whitelist</em>"</p></li>
  </ul>
  
  <p><strong>Questions:</strong> </p>
  
  <ul>
  <li><p>Has this worked for anyone?</p></li>
  <li><p>What's the best way to modify .htaccess or robots.txt to accomplish that?</p></li>
  <li><p>I am facing the same issue with Tumblr as well. I have verified that w/o the parentheses, the share it button works fine. If nothing else works, should I remove all the parentheses from the URIs?</p></li>
  </ul>