Welcome to Centmin Mod Community
Register Now

Curl to Facebook oembed returning wrong language

Discussion in 'Other Web Apps usage' started by Revenge, Dec 13, 2016.

  1. Revenge

    Revenge Active Member

    288
    64
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +227
    Local Time:
    9:31 AM
    1.9.x
    10.1.x
    Ok, so the embed facebook posts in my IPS forum started appearing in Arabic language.

    So i entered the vps and did teh following:

    Code:
    curl https://www.facebook.com/plugins/video/oembed.json/?url=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F10153231379946729%2F
    This was the result:

    Code:
    {"author_name":"Facebook","author_url":"https://www.facebook.com/facebook/","provider_url":"https://www.facebook.com","provider_name":"Facebook","success":true,"height":281,"html":"\u003Cdiv id=\"fb-root\">\u003C/div>\n\u003Cscript>(function(d, s, id) {\n  var js, fjs = d.getElementsByTagName(s)[0];\n  if (d.getElementById(id)) return;\n  js = d.createElement(s); js.id = id;\n  js.src = \"//connect.facebook.net/ar_AR/sdk.js#xfbml=1&version=v2.3\";\n  fjs.parentNode.insertBefore(js, fjs);\n}(document, 'script', 'facebook-jssdk'));\u003C/script>\u003Cdiv class=\"fb-video\" data-href=\"https://www.facebook.com/facebook/videos/10153231379946729/\">\u003Cblockquote cite=\"https://www.facebook.com/facebook/videos/10153231379946729/\" class=\"fb-xfbml-parse-ignore\">\u003Ca href=\"https://www.facebook.com/facebook/videos/10153231379946729/\">How to Share With Just Friends\u003C/a>\u003Cp>How to share with just friends.\u003C/p>\u062a\u0645 \u0646\u0634\u0631\u0647 \u0628\u0648\u0627\u0633\u0637\u0629 \u200f\u200e\u003Ca href=\"https://www.facebook.com/facebook/\">Facebook\u003C/a>\u200e\u200f \u0641\u064a 5 \u062f\u064a\u0633\u0645\u0628\u0631\u060c 2014\u003C/blockquote>\u003C/div>","type":"video","version":"1.0","url":"https://www.facebook.com/facebook/videos/10153231379946729/","width":500}
    TL: DR in the response above, there is this: connect.facebook.net/ar_AR/sdk.js

    What setting may be causing Facebook to respond with ar_AR?
     
  2. Revenge

    Revenge Active Member

    288
    64
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +227
    Local Time:
    9:31 AM
    1.9.x
    10.1.x
    Inside of locale.conf i have this:

     
  3. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    6:31 PM
    Nginx 1.13.x
    MariaDB 5.5
  4. Revenge

    Revenge Active Member

    288
    64
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +227
    Local Time:
    9:31 AM
    1.9.x
    10.1.x
    I don't think its related with facebook. I tried in other servers i have and its responding with us_US. It must be some kind of configuration. Strange.
     
  5. Revenge

    Revenge Active Member

    288
    64
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +227
    Local Time:
    9:31 AM
    1.9.x
    10.1.x
    Ok, if i do this, it works:

    Code:
    curl -H 'Accept-Language: pt' https://www.facebook.com/plugins/video/oembed.json/?url=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F10153231379946729%2F
    Is there any way to force the Accept-Language in CURL? Or, where does CURL goes getting the language if we don't set any? I think my problem is there.
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    6:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    what's output for
    Code (Text):
    locale
    

    i.e.
    Code (Text):
    locale
    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT="en_US.UTF-8"
    LC_IDENTIFICATION="en_US.UTF-8"
    LC_ALL=
    
     
  7. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    6:31 PM
    Nginx 1.13.x
    MariaDB 5.5
  8. Revenge

    Revenge Active Member

    288
    64
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +227
    Local Time:
    9:31 AM
    1.9.x
    10.1.x
    I have this:

    Code:
    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT="en_US.UTF-8"
    LC_IDENTIFICATION="en_US.UTF-8"
    LC_ALL=
    I changed it to pt_PT UTF8, but its the same result.
     
  9. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    6:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    have you asked on IPB forums could be specific to the software? though curl command line shouldn't do that too ?
     
  10. Revenge

    Revenge Active Member

    288
    64
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +227
    Local Time:
    9:31 AM
    1.9.x
    10.1.x
    I opened a ticket with them, but they told me its a server issue, which seems they are correct. I also suggested them they should add the accept-language parameter to curl, and even better, make it possible for us to choose the language.
     
  11. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    6:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    indeed though no idea why you're picking on Arabic language !
     
  12. Revenge

    Revenge Active Member

    288
    64
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +227
    Local Time:
    9:31 AM
    1.9.x
    10.1.x
    Ok, with my suggestion, Invision now use the accept-language in the curl request.
    They also applied it on my site and is working as intended now.
     
    • Like Like x 1
  13. eva2000

    eva2000 Administrator Staff Member

    30,168
    6,784
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    6:31 PM
    Nginx 1.13.x
    MariaDB 5.5
    wow nice and fast support and deployment indeed :D
     
  14. Revenge

    Revenge Active Member

    288
    64
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +227
    Local Time:
    9:31 AM
    1.9.x
    10.1.x
    Ya, its one of the best things they have :D
     
    • Like Like x 1