Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author WP All Import

    (@wpallimport)

    This data would be stored in the page’s HTTP header. This is something that you would probably configure with your theme or a multilingual plugin like WPML, but I’m not sure. Unless you have a way to store this header info in the database (in a custom field or something) there isn’t any way to import this data with WP All Import.

    Thread Starter Fadi Chamoun

    (@faddoo)

    Nothing with “get_file_curl.php” ?
    Maybe accepting header from there while requesting download from the URL?

    I have a CURL code, but i dont know how to change the URL to the import URL using from the plugin import settings (wp-admin)

    $curl = curl_init();
    
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://api.arbetsformedlingen.se/af/v0/platsannonser/matchning?lanid=6&antalrader=5",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "GET",
      CURLOPT_HTTPHEADER => array(
        "accept: application/json",
        "accept-encoding: UTF-8",
        "accept-language: sv",
        "cache-control: no-cache",
        "from: [email protected]",
      ),
    ));
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
    Thread Starter Fadi Chamoun

    (@faddoo)

    I also saw that the uploading from URL is going through wp_ajax_upload_resource.php

    Plugin Author WP All Import

    (@wpallimport)

    WP All Import helps you import data, automating the same process that would be used when manually creating the data.

    How would you manually set this HTTP header for each page? If you can answer that question we can tell you how (or if) you can import this data with WP All Import.

    Thread Starter Fadi Chamoun

    (@faddoo)

    All that i want is to import a json through this link “https://api.arbetsformedlingen.se/af/v0/platsannonser/matchning?lanid=6&antalrader=5”
    which is requesting headers. All I want is to put headers into the file that is downloading that file. Any idea?

    Plugin Author WP All Import

    (@wpallimport)

    Hey faddoo

    It seems that you actually already have your solution. On your first followup you provided the code for a CURL function that retrieves the JSOn feed with those headers. You could simply make a script out of that, which will output the contents of the retrieved json feed.

    The simply use the URL to that script as the data source for the import. That way the import is already getting the authenticated feed, while the authentication is handled by your custom script.

    Thread Starter Fadi Chamoun

    (@faddoo)

    I managed to fix it, thanks for your time anyway!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to fix the [Accept-Language] error while importing xml/json from url?’ is closed to new replies.