title: How do I make a POST using X-HTTP-Method-Override with a PHP curl request?
body: <p>I'm working with the Google Translate API and there's the possibility that I could be sending in quite a bit of text to be translated. In this scenerio Google recommends to do the following:</p>
  
  <blockquote>
    <p>You can also use POST to invoke the API if you want to send more data
    in a single request. The q parameter in the POST body must be less
    than 5K characters. To use POST, you must use the
    X-HTTP-Method-Override header to tell the Translate API to treat the
    request as a GET (use X-HTTP-Method-Override: GET). <a href="http://code.google.com/apis/language/translate/v2/using_rest.html" rel="noreferrer">Google Translate API Documentation</a></p>
  </blockquote>
  
  <p>I know how to make a normal POST request with CURL:</p>
  
  <pre><code>$curl = curl_init();
  curl_setopt($curl, CURLOPT_URL, $url);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  $response = curl_exec($curl);
  curl_close($curl);
  echo $response;
  </code></pre>
  
  <p>But how do I modify the header to use the X-HTTP-Method-Override?</p>