title: How to get JSON response using curl
body: <p>Hey there I am started to learn foursquare API, but I am stuck at getting an Access Token.
  Here is a part from the code I found in SO.</p>
  
  <pre><code>        // build url
      $url = 'https://foursquare.com/oauth2/access_token';
      $url .= '?client_id='.CLIENT_ID;
      $url .= '&amp;client_secret='.CLIENT_SECRET;
      $url .= '&amp;grant_type=authorization_code';
      $url .= '&amp;redirect_uri=**********/callback'; //change to your 4sq callback
      $url .= '&amp;code='.$code;
  
      // call to https://foursquare.com/oauth2/access_token with $code
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_URL, $url);
      $result = curl_exec($ch);
  </code></pre>
  
  <p>However this did not work, so I have tried to find error. First echoed $url and manually clicked on that link. It worked, foursquare has returned me an access token in json format. So the problem is in the curl part of the code.</p>
  
  <p>Can you find my error? and more importantly can you suggest me some resources to study on curl?</p>
  
  <p>EDIT:
  I did a var_dump($result)  and the output is 'boolean false'</p>