Answers.Body: <p>So, here's what I've found after after some research. It is certainly possible to create your own datatypes. Support for it, looks to have been added since around 2.0.1. Previously, the feed type field wasn't able to have custom types as it was a fixed list, but with hooks it is now possible. There is a great plugin that shows how to add custom data types here:</p>
  
  <p><a href="https://github.com/surprisehighway/craft-feedmehelper" rel="nofollow noreferrer">https://github.com/surprisehighway/craft-feedmehelper</a></p>
  
  <p>You do need a Pro license to use custom data types however.</p>
  
  <p>Unfortunately, the documentation for data types is currently TBA on Verbb's website: <a href="https://verbb.io/craft-plugins/feed-me/docs/developers/data-types" rel="nofollow noreferrer">https://verbb.io/craft-plugins/feed-me/docs/developers/data-types</a>, so this is going off looking through the code of both the helper plugin and FeedMe itself. Hopefully that will be added at some point. </p>
  
  <p>The way to add your own data/feed type is to call the <code>registerFeedMeDataTypes()</code> function in a plugin, register the datatype:</p>
  
  <pre><code>public function registerFeedMeDataTypes()
  {
      return array(
          new MyCustomFeedMeDataType(),
      );
  }
  </code></pre>
  
  <p><em>You'd import the <code>MyCustomFeedMeDataType</code> class, with <code>Craft::import</code> in the plugin <code>init()</code> function</em></p>
  
  <p>Then in your datatype class:</p>
  
  <pre><code>&lt;?php
  namespace Craft;
  
  class MyCustomFeedMeDataType extends BaseFeedMeDataType
  {
     // Custom data type stuff here
  }
  </code></pre>
  
  <p>The datatype should then appear in the feed type dropdown within the FeedMe feeds section in Craft for selection. By default it will use part of the class name for the field label/value, you can also set a specific name, according to this pull request:</p>
  
  <p><a href="https://github.com/verbb/feed-me/pull/172" rel="nofollow noreferrer">https://github.com/verbb/feed-me/pull/172</a></p>
  
  <p>Quick and reasonably simple in the end, but certainly provides better custom integration options for my project now!</p>
  
  <p>Hope this helps other Craft CMS folk!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-26T19:44:12.840Z
Answers.LastActivityDate: 2018-06-27T06:57:17.017Z
Answers.LastEditDate: 2018-06-27T06:57:17.017Z
Answers.UserDisplayName: James White
Body: <p>I have a Craft 2 project which is using an older version of the FeedMe plugin 1.x. In order to use a specific XML feed this site uses, a custom XML feed service was implemented with a custom feed type available to select from the feed type option in Craft FeedMe back-end, but this involved directly editing the FeedMe plugin files. </p>
  
  <p>The reason for this is because a specific authentication mechanism is required before being able to interact with the feed in the form of a unique token passed by the Authorization HTTP header obtained from a separate auth endpoint first. This is then added to the feed request via curl, so its authenticated and returns data.</p>
  
  <p>The current implementation added an additional service within <code>feedme/services/</code> which extends <code>FeedMe_FeedXMLService</code> to handle the token authorisation part and added an additional enum type, record type, model type. In theory could a separate plugin be created that provides the service without having to modify the core plugin? Or could the approach be different given the changes with the 2.x version of the plugin?</p>
  
  <p>It looks v2.x has changed quite a bit looking at the core plugin files with potentially more options for customisation, but I'm not sure if the implementation we have is possible to move to 2.x easily.</p>
  
Tags: <plugin-feedme>
Title: Using FeedMe 2.x with a custom authentication mechanism
ThreadText: # Using FeedMe 2.x with a custom authentication mechanism
  
  (Asked by: username_0 on 2018-06-24)
  
  I have a Craft 2 project which is using an older version of the FeedMe plugin 1.x. In order to use a specific XML feed this site uses, a custom XML feed service was implemented with a custom feed type available to select from the feed type option in Craft FeedMe back-end, but this involved directly editing the FeedMe plugin files.
  
  The reason for this is because a specific authentication mechanism is required before being able to interact with the feed in the form of a unique token passed by the Authorization HTTP header obtained from a separate auth endpoint first. This is then added to the feed request via curl, so its authenticated and returns data.
  
  The current implementation added an additional service within `feedme/services/` which extends `FeedMe_FeedXMLService` to handle the token authorisation part and added an additional enum type, record type, model type. In theory could a separate plugin be created that provides the service without having to modify the core plugin? Or could the approach be different given the changes with the 2.x version of the plugin?
  
  It looks v2.x has changed quite a bit looking at the core plugin files with potentially more options for customisation, but I'm not sure if the implementation we have is possible to move to 2.x easily.
  
  **Tags:** plugin-feedme
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-06-26. Score: 1 | Accepted answer
  
  So, here's what I've found after after some research. It is certainly possible to create your own datatypes. Support for it, looks to have been added since around 2.0.1. Previously, the feed type field wasn't able to have custom types as it was a fixed list, but with hooks it is now possible. There is a great plugin that shows how to add custom data types here:
  
  <https://github.com/surprisehighway/craft-feedmehelper>
  
  You do need a Pro license to use custom data types however.
  
  Unfortunately, the documentation for data types is currently TBA on Verbb's website: <https://verbb.io/craft-plugins/feed-me/docs/developers/data-types>, so this is going off looking through the code of both the helper plugin and FeedMe itself. Hopefully that will be added at some point.
  
  The way to add your own data/feed type is to call the `registerFeedMeDataTypes()` function in a plugin, register the datatype:
  
  ```
  public function registerFeedMeDataTypes()
  {
      return array(
          new MyCustomFeedMeDataType(),
      );
  }
  
  ```
  
  *You'd import the `MyCustomFeedMeDataType` class, with `Craft::import` in the plugin `init()` function*
  
  Then in your datatype class:
  
  ```
  <?php
  namespace Craft;
  
  class MyCustomFeedMeDataType extends BaseFeedMeDataType
  {
     // Custom data type stuff here
  }
  
  ```
  
  The datatype should then appear in the feed type dropdown within the FeedMe feeds section in Craft for selection. By default it will use part of the class name for the field label/value, you can also set a specific name, according to this pull request:
  
  <https://github.com/verbb/feed-me/pull/172>
  
  Quick and reasonably simple in the end, but certainly provides better custom integration options for my project now!
  
  Hope this helps other Craft CMS folk!
  
  
  ---
  
  