EurActory Embed Tool


This API sits between the EurActory and a client website that would like to embed EurActory cards. It exists because:

Warning: This API uses screen scraping to extract data from the EurActory. If the EurActory HTML structure changes dramatically, the API may need tweeking to continue functioning.

Use

Note: jQuery v1.11 must be loaded before the script.

To load the script itself:

<script src='//assets.euractiv.com/euractory/euractory-min.js'></script>

The script creates creates a global object at window.EA.euractory.

The embeds are marked up for bootstrap display; to include more base styling include the stylesheet:

<link href='//assets.euractiv.com/euractory/euractory-min.css' rel='stylesheet'>

Documentation and Examples


Use the function window.EA.euractory.profile. It accepts two parameters:

  • search_term: (string) the search term for locating the person, normally the person's name
  • selector: (string) css selector for the element to append the profile card into. The contents of the first matched element will be removed and replaced with the EurActory profile. If there are no results, the first matched element will be removed.

To localize the script, use the function window.EA.euractory.localize. It accepts two parameters, the first being the string to localize and the second the localized value. Alternately, it will accept an object where the properties are the string to localize and the values are the localized value.

Loading...
<div id='euractory-person-example'>Loading...</div>
<script type='text/javascript'>(function (global) {
    global.EA.euractory.localize({
        'Latest tweets': '<i class=\"fa fa-twitter\"></i> Latest Tweets',
        'Expert at:': '<i class=\"fa fa-bookmark-o\"></i> Expertise',
        'Latest news': '<i class=\"fa fa-newspaper-o\"></i> In the news',
    });    
    global.EA.euractory.profile('maroš-šefčovič', '#euractory-person-example');    
}(window));</script>

Use the function window.EA.euractory.ranking. It accepts two parameters:

  • search_term: the search term for locating the ranking, normally the policy topic
  • append_to: the CSS selector to append the search results to. Important: The container will have any existing HTML removed and replaced with the matching person; if there is no match the container will be removed.
  • num_results: the number of results to show, defaults to 4. Maximum limited by EurActory search pagination, which was 12 at the time of writing.
Loading...
<div id='euractory-ranking-example'>Loading...</div>
<script type='text/javascript'>(function (global) {
    global.EA.euractory.ranking('energy union', '#euractory-ranking-example', 5);
 }(window));</script>

Internal use only! The endpoint should not be called directly and is subject to change without notice; this section exists for documentation puposes only.

The profile JSON endpoint is: //assets.euractiv.com/euractory/profile.php. It accepts two query parameters:

  • uri: (string) [required] the relative uri to the profile, as returned by the search API endpoint.
  • mini: (bool) [optional] return a minified version of the profile.
$ wget -q0 http://assets.euractiv.com/euractory/profile.php?uri=%2Fangela-merkel;
{
    "img": null
}
$ wget -q0 http://assets.euractiv.com/euractory/profile.php?uri=%2Fangela-merkel&mini=1;
{
    "img": null
}
<pre>
$ wget -q0 http://assets.euractiv.com/euractory/profile.php?uri=%2Fangela-merkel;
{
    &quot;img&quot;: null
}
$ wget -q0 http://assets.euractiv.com/euractory/profile.php?uri=%2Fangela-merkel&mini=1;
{
    &quot;img&quot;: null
}</pre>


Internal use only! The endpoint should not be called directly and is subject to change without notice; this section exists for documentation puposes only.

The search JSON endpoint is: http://assets.euractiv.com/euractory/search.php. It accepts two query parameters:

  • term: (string) [required] the search term
  • count: (integer) [optional default 1] the number of terms to return, limited to the pagination value of the EurActory (12 at time of writing).
$ wget -q0 http://assets.euractiv.com/euractory/search.php?term=energy&count=3;

Error [E_USER_NOTICE]: 301: SSL certificate problem: unable to get local issuer certificate (https://euractory.eucommunity.eu/search?keys=energy) (modules/inc-http.php:337)
Error [E_NOTICE]: Undefined index: uris (plugins/euractory/search.php:21)
Error [E_WARNING]: array_slice() expects parameter 1 to be array, null given (plugins/euractory/search.php:21)
{ "uris": null }
<pre>$ wget -q0 http://assets.euractiv.com/euractory/search.php?term=energy&count=3;

<b>Error [E_USER_NOTICE]:</b> 301: SSL certificate problem: unable to get local issuer certificate (https://euractory.eucommunity.eu/search?keys=energy) (modules/inc-http.php:337)<br>

<b>Error [E_NOTICE]:</b> Undefined index: uris (plugins/euractory/search.php:21)<br>

<b>Error [E_WARNING]:</b> array_slice() expects parameter 1 to be array, null given (plugins/euractory/search.php:21)<br>
{
    "uris": null
}</pre>

System Status


Cache

The database that powers this API is currently using 39.3 KB.

Expired items were last cleaned from the cache never. The database was last vacuumed never.

To ensure that the database is regularly cleaned, make sure the following line is in your cron tab (adjusting the frequency to your needs):

/15 * * * wget -q -O - http://assets.euractiv.com/euractory/clean-cache.php

Driver: sqlite | Clean cache now.

Warning! It looks like the database isn't being cleaned regularly. Are you sure cron is configured?


Configuration

Configuration is located in the file /config/euractory.php. If you do not have the ability to modify this file, contact your administrator to have options changed. The configuration file should contain an array with the name $config containing the following offsets:

NameTypeDescriptionCurrent Setting
search_urlstringThe base URL for the search page
http://euractory.eucommunity.eu/search?keys=
search_xpathstringThe XPath selector for profile page links in the search results
//a[contains(@class, "title")]
search_ranking_xpathstringThe XPath selector to determine if a search result is a ranking
//body[contains(@class,"page-topic")]
profile_urlstringThe base URL for a profile page
http://euractory.eucommunity.eu
profile_xpathstringThe XPath selector for the profile container element
//div[contains(@class, "classified_in")]
profile_img_xpathstringThe XPath selector for the profile image
//*[contains(@class, "expertImage")]//a/img
profile_title_xpathstringThe XPath selector for the job title
//h1
profile_positions_xpathstringThe XPath selector for profile job positions
//*[contains(@class, "expertPosition")]//div//h4
profile_tabs_xpathstringTHe XPath selector for the "more details" tabs
//*[contains(@class, "quick-accordion")]//h3
callmap_driverstringThe callmap driver to use, either "sqlite", "fsstore" or "noop"
noop
callmap_labelsarrayLabels for the callmap, where the key is the regular expression to match and the value is the label to useLogin to view this setting
callmap_visualize_defaultarrayNodes to visualize by defaultLogin to view this setting
callmap_probabilityintegerProbability that a given hit will log. Important for high traffic sites. Set higher for lower probability.
1000
cal_ttlintegerThe time, in seconds, to cache items before revalidating
86400
cal_driverstringThe cache driver to use, either "fs" or "sqlite" or "noop"
sqlite
http_allowed_domainsarrayAllowed domains for fetching assets or generating URLsLogin to view this setting
http_allowed_urlsarraySpecified URLs or regular expressions of specified URLs match for fetching assets or generating URLsLogin to view this setting
http_connect_timeoutintegerThe amount of time, in seconds, that cURL should wait before returning an error status. 15 is a good value for most cases.
15