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.
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'>
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 nameselector
: (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.
<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 topicappend_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.<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 https://assets.euractiv.com/euractory/profile.php?uri=%2Fangela-merkel; { "img": null } $ wget -q0 https://assets.euractiv.com/euractory/profile.php?uri=%2Fangela-merkel&mini=1; { "img": null }
<pre>
$ wget -q0 https://assets.euractiv.com/euractory/profile.php?uri=%2Fangela-merkel;
{
"img": null
}
$ wget -q0 https://assets.euractiv.com/euractory/profile.php?uri=%2Fangela-merkel&mini=1;
{
"img": 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: https://assets.euractiv.com/euractory/search.php
.
It accepts two query parameters:
term
: (string) [required] the search termcount
: (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 https://assets.euractiv.com/euractory/search.php?term=energy&count=3; Error [E_WARNING]: htmlentities(): charset `ASCII' not supported, assuming utf-8 (plugins/euractory/functions.php
<pre>$ wget -q0 https://assets.euractiv.com/euractory/search.php?term=energy&count=3;
<b>Error [E_WARNING]:</b> htmlentities(): charset `ASCII' not supported, assuming utf-8 (plugins/euractory/functions.php</pre>
The database that powers this API is currently using
39.2 MB
.
Expired items were last cleaned from the cache 1 days ago. The database was last vacuumed 1 days ago.
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 - https://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 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:
Name | Type | Description | Current Setting |
---|---|---|---|
search_url | string | The base URL for the search page | http://euractory.eucommunity.eu/search?keys= |
search_xpath | string | The XPath selector for profile page links in the search results | //a[contains(@class, "title")] |
search_ranking_xpath | string | The XPath selector to determine if a search result is a ranking | //body[contains(@class,"page-topic")] |
profile_url | string | The base URL for a profile page | http://euractory.eucommunity.eu |
profile_xpath | string | The XPath selector for the profile container element | //div[contains(@class, "classified_in")] |
profile_img_xpath | string | The XPath selector for the profile image | //*[contains(@class, "expertImage")]//a/img |
profile_title_xpath | string | The XPath selector for the job title | //h1 |
profile_positions_xpath | string | The XPath selector for profile job positions | //*[contains(@class, "expertPosition")]//div//h4 |
profile_tabs_xpath | string | THe XPath selector for the "more details" tabs | //*[contains(@class, "quick-accordion")]//h3 |
callmap_driver | string | The callmap driver to use, either "sqlite", "fsstore" or "noop" | noop |
callmap_labels | array | Labels for the callmap, where the key is the regular expression to match and the value is the label to use | Login to view this setting |
callmap_visualize_default | array | Nodes to visualize by default | Login to view this setting |
callmap_probability | integer | Probability that a given hit will log. Important for high traffic sites. Set higher for lower probability. | 1000 |
cal_ttl | integer | The time, in seconds, to cache items before revalidating | 86400 |
cal_driver | string | The cache driver to use, either "fs" or "sqlite" or "noop" | sqlite |
http_allowed_domains | array | Allowed domains for fetching assets or generating URLs | Login to view this setting |
http_allowed_urls | array | Specified URLs or regular expressions of specified URLs match for fetching assets or generating URLs | Login to view this setting |
http_connect_timeout | integer | The amount of time, in seconds, that cURL should wait before returning an error status. 15 is a good value for most cases. | 15 |