Retrieving data from sharepoint in drupal

Problem:
I am going to create a Drupal site for a company that stores a lot of data in a sharepoint environment (products, recipes, etc.). I need to somehow get this information in my Drupal system. It is advisable to save it as Drupal nodes.
This information will also be edited / added to the sharepoint system, so instead of just saving the data in drupal, it will also have to regularly check for updates.

One idea for the solution is to use some kind of web service to retrieve the data, but I have no idea how this will be done in drupal.

So, my question (s): Has anyone done something like this, if so, or does anyone have any suggestions as to how this could be done?

Any answers would be highly appreciated.

/ Anders

+4
source share
5 answers

I highly recommend that you carefully study the FeedAPI module and its extensions .

I have successfully used it:

  • out of the box to create a node from RSS feeds
  • with minor changes to create a node from the contents of the Webservice
  • as a drawing / example for implementing a custom module that creates nodes from the contents of another Webservice (some special needs there that require a special solution)

If, as you think, you have some control over how sharepoint data becomes available, you should be able to use FeedAPI successfully without any changes at all, but you may need to implement your own parser extension (again, check additional modules already written for the FeedAPI extension for examples, if not solutions).

+3
source

We did this on many of the web services we created, and will do it soon for Sharepoint. As you say, you can get the data in XML. So you just need 1) Get XML data 2) XML data analysis 3) Return now readable data to a block in Drupal

For 1, you need to open any access to the firewall and provide a public XML channel or set it only to access the IP address of the Drupal server or some other authentication mechanism. For 2PHP, you get many XML parsing options. We created one module to process the XML service, and then we call it from another module that handles the display, theme, etc. Below I will first provide an example of two functions from an XML module, and then an example of how you can use it in another module.

Here is from the XML module.

/** * Retrieving XML data from the URL * * @param $url * The url to retrieve the data * @param $replace_special_characters * Replace special character to HTML format * * @return parse result as struct */ function xmlservice_parse($url, $replace_special_characters = FALSE) { $http_contents = drupal_http_request($url); if (!isset($http_contents->data)) { throw new RuntimeException("Cannot get contents from the URL"); }//if if($replace_special_characters) $http_contents_data = str_replace('&','&', $http_contents->data); else $http_contents_data = $http_contents->data; $xml_parser = xml_parser_create(); xml_parse_into_struct($xml_parser, $http_contents_data, $result); xml_parser_free($xml_parser); return $result; } /** * Retrieving XML data as Dom document from the URL * * @param $url * The url to retrieve the data * @param $replace_special_characters * Replace special character to HTML format * * @return result as Dom Document */ function xmlservice_parse_to_dom($url, $replace_special_characters = FALSE) { $http_contents = drupal_http_request($url); if (isset($http_contents->error)) { throw new RuntimeException($http_contents->error); }//if if (!isset($http_contents->data)) { throw new RuntimeException("Cannot get contents from the URL"); }//if if($replace_special_characters){ $http_contents_data = str_replace('&','&', $http_contents->data); }//if else{ $http_contents_data = $http_contents->data; }//else $dom_document = new DomDocument; /* load htmlinto object */ $dom_document->loadXML($http_contents_data); /* discard white space */ $dom_document->preserveWhiteSpace = false; return $dom_document; } 

Then just write your code to create the block. If you do not know how to do this, look at http://www.nowarninglabel.com/home/creating-a-new-custom-module-in-drupal-6 , which creates a simple block. Then for content, you can simply call one of the above functions in an XML document, for example $ content = xml_service_parse (' http://sharepoint.example.com/some/thing/feed.xml ');

If you want to parse a node, you can simply use the XML function, but instead use node_save () to programmatically create the node: http://api.drupal.org/api/function/node_save I haven't looked at the available Sharepoint services too much , but you could just parse the XML into a dom document, as shown above, and then loop through it, creating a node for each XML node that matches your criteria.

And if you want more work done for

Hope this was helpful. Feel free to ask for details.

+2
source

Sharepoint stores data in an MS SQL database, right? My colleague wrote a good outline of the process that we used to move data from MS SQL to Drupal .

0
source

You can definitely talk to him through web services. We previously linked the Drupal website with MS Great Plains.

0
source

SharePoint provides web services by default. If you have access to the elements of the SharePoint website, you can also access them through the web services. Keep in mind to pass the correct user credentials when accessing web services from code.

If you only need readaccess handling in Drupal, you can also use rss feeds. This can be a bit more complicated with rss feeds for filtering, sorting, or searching for a specific item.

Reading directly from the database is not recommended, as Microsoft does not guarantee that dataschema will remain unchanged between software updates.

0
source

Source: https://habr.com/ru/post/1304279/


All Articles