cUrl set language header

directory picture directory · Feb 25, 2013 · Viewed 23.3k times · Source

How can I set a language header for my cURL request? e.g. now I get the homepage of facebook.com in dutch, probably because my server is in the Netherlands / default language send by headers?..

I prefer english before dutch in this case so I tried to set an httpheader in curl but I make no sense? What do I do wrong or what should I have to set?

(zend notation)

CURLOPT_HTTPHEADER => 'Accept-Language: en-US;q=0.6,en;q=0.4',

Thanks in advance!

Answer

doub1ejack picture doub1ejack · Nov 8, 2016

I arrived at this page looking for a way to pass the language header to curl at the command line. If you want to set headers in a bash one-liner, use -H Accept-Language

$ curl -s -H 'Accept-Language: es'  -XGET "http://www.google.com"

<!doctype html>
  <html itemscope="" itemtype="http://schema.org/WebPage" lang="es-419">
    <head>
      <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
      <meta content="/logos/doodles/2016/united-states-elections-2016-4829342880235520-hp.gif" itemprop="image">
      <meta content="Tu voz importa. �Encuentra tu casilla y vota! g.co/elections/dondevotar #Everyonein2016 #GoogleDoodle" property="og:description">
      ...