title: google url shortener api with wp_remote_post
body: <p>I try to make google url shortener with wp_remote_post()</p>
  
  <p>but I got error result,</p>
  
  <p>I know how to use CURL, but CURL not allowed in WordPress!</p>
  
  <hr>
  
  <p>This resource for API with WordPress:</p>
  
  <p><a href="http://codex.wordpress.org/Function_Reference/wp_remote_post" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_remote_post</a></p>
  
  <p><a href="http://codex.wordpress.org/Function_Reference/wp_remote_retrieve_body" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_remote_retrieve_body</a></p>
  
  <p><a href="http://codex.wordpress.org/HTTP_API#Other_Arguments" rel="nofollow">http://codex.wordpress.org/HTTP_API#Other_Arguments</a></p>
  
  <p><a href="http://codex.wordpress.org/Function_Reference/wp_remote_post#Related" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_remote_post#Related</a></p>
  
  <hr>
  
  <p>This google url shortener API docs:</p>
  
  <p><a href="https://developers.google.com/url-shortener/v1/getting_started#shorten" rel="nofollow">https://developers.google.com/url-shortener/v1/getting_started#shorten</a></p>
  
  <hr>
  
  <p>This is my code:</p>
  
  <pre><code>function google_url_shrt{
      $url = 'http://example-long-url.com/example-long-url'; // long url to short it
      $args = array(
              "headers"   =&gt;  array( "Content-type:application/json" ),
              "body"      =&gt;  array( "longUrl" =&gt; $url )
          );
  
      $short = wp_remote_post("https://www.googleapis.com/urlshortener/v1/url", $args);
      $retrieve = wp_remote_retrieve_body( $short );
      $response = json_decode($retrieve, true);
  
      echo '&lt;pre&gt;';
      print_r($response);
      echo '&lt;/pre&gt;';
  }
  </code></pre>