title: store the PERMALINK in a PHP variable
body: <p>I have this code to count all the social sites shares in my posts. The problem with the code is the permalink is static.</p>
  
  <p>If you noticed, i stored the permalink in <code>$myurl</code> variable using <code>get_permalink();</code>, the problem with the code is once I change the link "<a href="http://www.bendaggers.com/how-to-write-a-killer-resume-that-lands-an-interview/" rel="nofollow">http://www.bendaggers.com/how-to-write-a-killer-resume-that-lands-an-interview/</a>", it gives me tons of errors such as:</p>
  
  <blockquote>
    <p>file_get_contents(<a href="http://graph.facebook.com/?id=" rel="nofollow">http://graph.facebook.com/?id=</a>$myurl): failed to
    open stream: HTTP request failed!</p>
  </blockquote>
  
  <p>Here's my code:</p>
  
  <pre><code>$myurl = get_permalink();
  $url = urlencode($url);
  
  $facebook_like_share_count = function ( $url ) {
      $api = file_get_contents( 'http://graph.facebook.com/?id=' . $url );
      $count = json_decode( $api );
      return $count-&gt;shares;
  };
  
  
  $twitter_tweet_count = function ( $url ) {
      $api = file_get_contents( 'https://cdn.api.twitter.com/1/urls/count.json?url=' . $url );
      $count = json_decode( $api );
      return $count-&gt;count;
  };
  
  
  $pinterest_pins = function ( $url ) {
      $api = file_get_contents( 'http://api.pinterest.com/v1/urls/count.json?callback%20&amp;url=' . $url );
      $body = preg_replace( '/^receiveCount\((.*)\)$/', '\\1', $api );
      $count = json_decode( $body );
      return $count-&gt;count;
  };
  
  
  
  
  echo twitter_tweet_count( 'http://www.bendaggers.com/how-to-write-a-killer-resume-that-lands-an-interview/' );
  
  echo "&lt;br&gt;";
  
  echo facebook_like_share_count( 'http://www.bendaggers.com/how-to-write-a-killer-resume-that-lands-an-interview/' );
  
  echo "&lt;br&gt;";
  
  echo pinterest_pins( 'http://www.bendaggers.com/how-to-write-a-killer-resume-that-lands-an-interview/' );
  
  echo "&lt;br&gt;";
  
  
  ?&gt;
  </code></pre>
  
  <p>To add, the <code>get_permalink</code> function returns the current URL of the active page. I'm doing this to integrate it to my wordpress website and show the exact number of shares (facebook, twitter, linkedin and pinterest). The code above doesnt return the URL of the current page. It's static. </p>