Setup on a client site running Drupal 7

Instructions to set up a Drupal 7 site to be able to query data from the Encyclopedia of World Problems and Human Potential (EWPHP).

Install Clients

Download and enable the Web Service Clients module (https://www.drupal.org/project/clients).

At admin/structure/clients, click "Add clients connection" and fill in the details:

  • Connection type ... e.g. "drupal_services"
  • Connection label ... e.g. "api_10"
  • Connection endpoint ... https://edit.ewphp.org/en/api/1.0
  • Service username and password: use the credentials received from an EWPHP representative (describe your motivation and place a request at https://edit.ewphp.org/en/contact)

--> Click "Save the connection"

You can set the returned dat to be cached (recommended!) at admin/structure/clients/settings

Query remote data

Get a list of nodes

In the following example we will retrieve a information 10 published nodes of content type "problem" in English language, sorted descending by the date of last change. Instead of all fields we only ask for fields "changed" and "title". If we need the next page in the list, we simply increase the number assigned to parameter "page".

<?php
try {
 
// Retrieve data from the remote site
 
$result = clients_connection_call('api_10', 'entity_node?parameters[type]=problem&parameters[language]=en&parameters[status]=1&page=0&pagesize=10&sort=changed&direction=DESC&fields=changed,title', 'GET');
}
catch (
Exception $e) {
 
// Record the error message, if any
 
$message = $e->getMessage();
}
if (
$result){
  echo
'<ul>';
  foreach (
$result as $val){
    echo
'<li>' . $val->title . ' (' . date( 'Y-m-d H:i:s', $val->changed ) . ')' . '</li>';
  }
  echo
'</ul>';
}
?>
  • Fragmented business practices (2019-01-24 04:39:05)
  • Unbridled individualism (2019-01-24 04:39:05)
  • Dependence on religion (2019-01-24 04:39:05)
  • Anti-social behaviour (2019-01-24 04:39:05)
  • Anxiety (2019-01-24 04:39:05)
  • Social fragmentation (2019-01-24 04:39:05)
  • Fragmented social responsibility (2019-01-24 00:38:49)
  • Passive resistance (2019-01-24 00:38:49)
  • Ineffective war crime prosecution (2019-01-24 00:38:49)
  • Pacifism (2019-01-24 00:38:49)

Get one full node

To get all data for a given published node (identified by parameter "nid"), we can proceed as follows.

<?php
try {
 
// Retrieve data from the remote site
 
$result = clients_connection_call('api_10', 'entity_node?parameters[status]=1&parameters[nid]=132936', 'GET');
}
catch (
Exception $e) {
 
// Record the error message, if any
 
$message = $e->getMessage();
}
echo
'<pre>';
print_r($result[0]);
echo
'</pre>';
?>
stdClass Object
(
    [vid] => 328428
    [uid] => 1
    [title] => Famine
    [log] => 
    [status] => 1
    [comment] => 0
    [promote] => 0
    [sticky] => 0
    [ds_switch] => 
    [nid] => 132936
    [type] => problem
    [language] => en
    [created] => 981154800
    [changed] => 1528717680
    [tnid] => 0
    [translate] => 0
    [revision_timestamp] => 1528717680
    [revision_uid] => 0
    [field_name_s_] => stdClass Object
        (
            [und] => Array
                (
                    [0] => stdClass Object
                        (
                            [value] => Famine
                            [format] => 
                            [safe_value] => Famine
                        )

                    [1] => stdClass Object
                        (
                            [value] => Dependence on famine
                            [format] => 
                            [safe_value] => Dependence on famine
                        )

                    [2] => stdClass Object
                        (
                            [value] => Lack of food
                            [format] => 
                            [safe_value] => Lack of food
                        )

                    [3] => stdClass Object
                        (
                            [value] => Insufficient food supply
                            [format] => 
                            [safe_value] => Insufficient food supply
                        )

                    [4] => stdClass Object
                        (
                            [value] => Food poverty
                            [format] => 
                            [safe_value] => Food poverty
                        )

                    [5] => stdClass Object
                        (
                            [value] => Food deprivation
                            [format] => 
                            [safe_value] => Food deprivation
                        )

                )

        )

    [field_nature] => stdClass Object
        (
            [und] => Array
                (
                    [0] => stdClass Object
                        (
                            [value] => 

The major causes of famine are poverty, trade barriers, corruption, mismanagement, ethnic antagonism, anarchy, war, and male-dominated societies that deprive women of food. Local land depletion, itself a consequence of poverty and institutional failure, is also a factor. Those who are too poor to use sound farming practices are compelled to overexploit the resources on which they depend.

The problem of famine is manifold. 1. Once a famine has reached the proportions of a major disaster, it is too late to mount a fast and efficient relief operation. Supplies rushed to a country often get held up at the country's ports, unable to be distributed by the existing infrastructure. 2. Governmental organizations which issue relief aid are not set up to respond quickly or effectively, and volunteer agencies (which, not being bogged down in governmental bureaucracy, are quicker to respond) are neither designed nor equipped to cope with starving masses. 3. Information inadequacies exist. Although there are numerous statistics on crop failures or droughts, the study of more finely-tuned data such as the movements of local prices or mass migrations of people from their homes, is still in its infancy. 4. Attention must be paid to the governmental idiosyncracies, and to preferences of the donor countries; sometimes no action may be undertaken before an invitation is extended. 5. The governments of stricken countries may be unaware of or unconcerned with a rural famine; they may be unable to assemble, in enough time, the necessary technical case for aid; they may be unwilling to broadcast their problems to the world; and they may be hostile to western intervention.

Equally manifold are the problems confronting possible remedies. 1. Strategic stockpiles are needed in those countries usually most unlikely to be able to afford to keep such reserves, and they may well be prey to thievery or spoilage. 2. Too much developmental aid poured into an area can be impossible to absorb and/or can make farmers dependent upon such aid rather than their own resources. 3. Aid programmes are often tied to restrictions and priorities that are either impossible or fruitless to achieve. 4. Too many helpers often cause confusion with their conflicting 'solutions' or their jealous rivalries.

[format] => filtered_html ) ) ) [field_background] => Array ( ) [field_incidence] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [value] =>

The African continent in the mid 1980's suffered from famines on a scale never before witnessed. As of April 1985, 10 million people had abandoned their normal homes in search of food and water; 20 countries had been critically affected by drought; and 35 million lives were in danger.

In the 1990's, notable famines have been man-made and in war zones like Kosovo, Nicaragua, Tajikistan, Sierra Leone and Congo-Brazzaville.

[format] => filtered_html ) ) ) [field_claim] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [value] =>

Famine is not a condition of lack of food but of inadequate planning, inadequate notification, slow response, government pride, misdirected aid, uncoordinated relief agency field work, politics, lethargic bureaucracy, ignorance, and incompetence. It is a grave problem which shakes the entire political, economic, and social foundations on which the stable and prosperous future for developing countries was to have been built.

[format] => filtered_html ) [1] => stdClass Object ( [value] =>

Population growth, poverty and degradation of local resources often fuel one another. The amount of food in world trade is constrained less by the resource base than by the maldistribution of wealth.

 

[format] => filtered_html ) [2] => stdClass Object ( [value] =>

Just as classic humanitarianism was founded to ensure that soldiers wounded in battles between states were cared for as human beings, the new humanitarianism was founded to challenge the use of violence against noncombatants in civil wars. But in total wars where the aim is to subordinate, expel or eliminate a whole population, control of food becomes the means of choice to impose submission, flight or death.

[format] => filtered_html ) ) ) [field_counter_claim] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [value] =>

Famine relief efforts are little more than a panacea until the next, and perhaps more profound, famine occurs; and indeed, may be a futile attempt to deep alive those people which nature is culling off in an attempt to remedy a surplus situation.

[format] => filtered_html ) ) ) [field_broader] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [target_id] => 132869 ) [1] => stdClass Object ( [target_id] => 132943 ) [2] => stdClass Object ( [target_id] => 141183 ) [3] => stdClass Object ( [target_id] => 226705 ) ) ) [field_narrower] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [target_id] => 160291 ) [1] => stdClass Object ( [target_id] => 150650 ) ) ) [field_related] => Array ( ) [field_aggravates] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [target_id] => 142235 ) [1] => stdClass Object ( [target_id] => 142187 ) [2] => stdClass Object ( [target_id] => 155307 ) [3] => stdClass Object ( [target_id] => 136928 ) [4] => stdClass Object ( [target_id] => 149867 ) [5] => stdClass Object ( [target_id] => 155383 ) [6] => stdClass Object ( [target_id] => 134406 ) [7] => stdClass Object ( [target_id] => 145991 ) [8] => stdClass Object ( [target_id] => 138999 ) ) ) [field_aggravated_by] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [target_id] => 132954 ) [1] => stdClass Object ( [target_id] => 137178 ) [2] => stdClass Object ( [target_id] => 151211 ) [3] => stdClass Object ( [target_id] => 136933 ) [4] => stdClass Object ( [target_id] => 132922 ) [5] => stdClass Object ( [target_id] => 145424 ) [6] => stdClass Object ( [target_id] => 140344 ) [7] => stdClass Object ( [target_id] => 143726 ) [8] => stdClass Object ( [target_id] => 146175 ) [9] => stdClass Object ( [target_id] => 145425 ) [10] => stdClass Object ( [target_id] => 133079 ) [11] => stdClass Object ( [target_id] => 132471 ) [12] => stdClass Object ( [target_id] => 160290 ) [13] => stdClass Object ( [target_id] => 141150 ) [14] => stdClass Object ( [target_id] => 139716 ) [15] => stdClass Object ( [target_id] => 140346 ) [16] => stdClass Object ( [target_id] => 143020 ) [17] => stdClass Object ( [target_id] => 134751 ) [18] => stdClass Object ( [target_id] => 139715 ) ) ) [field_reduces] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [target_id] => 157012 ) [1] => stdClass Object ( [target_id] => 134519 ) ) ) [field_reduced_by] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [target_id] => 141741 ) ) ) [field_web_page_s_] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [url] => http://www.wfp.org/ [title] => United Nations World Food Programme [attributes] => Array ( ) ) [1] => stdClass Object ( [url] => http://www.ifpri.org/ [title] => International Food Policy Research Institute [attributes] => Array ( ) ) ) ) [field_type] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [tid] => 42164 ) ) ) [field_subject_s_] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [tid] => 844 ) [1] => stdClass Object ( [tid] => 538 ) [2] => stdClass Object ( [tid] => 343 ) [3] => stdClass Object ( [tid] => 829 ) [4] => stdClass Object ( [tid] => 850 ) [5] => stdClass Object ( [tid] => 388 ) [6] => stdClass Object ( [tid] => 232 ) ) ) [field_tags] => Array ( ) [field_docid] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [value] => 11203150 ) ) ) [field_strategy_ies_] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [value] => 12008880Monitoring food security [format] => [safe_value] => 12008880<VM>Monitoring food security ) [1] => stdClass Object ( [value] => 12016070Improving quality of human life [format] => [safe_value] => 12016070<VM>Improving quality of human life ) [2] => stdClass Object ( [value] => 12019210Exploiting global biological resources for new foods [format] => [safe_value] => 12019210<VM>Exploiting global biological resources for new foods ) [3] => stdClass Object ( [value] => 12023860Reducing meat consumption to conserve grain [format] => [safe_value] => 12023860<VM>Reducing meat consumption to conserve grain ) [4] => stdClass Object ( [value] => 12710040Accumulating global food stocks [format] => [safe_value] => 12710040<VM>Accumulating global food stocks ) [5] => stdClass Object ( [value] => 12911260Providing food aid [format] => [safe_value] => 12911260<VM>Providing food aid ) [6] => stdClass Object ( [value] => 13127630Researching causes of starvation [format] => [safe_value] => 13127630<VM>Researching causes of starvation ) [7] => stdClass Object ( [value] => 13214060Increasing global food production [format] => [safe_value] => 13214060<VM>Increasing global food production ) [8] => stdClass Object ( [value] => 13218160Using famine [format] => [safe_value] => 13218160<VM>Using famine ) [9] => stdClass Object ( [value] => 13246940Reducing famine [format] => [safe_value] => 13246940<VM>Reducing famine ) [10] => stdClass Object ( [value] => 13293350Reducing incidence of malnutrition [format] => [safe_value] => 13293350<VM>Reducing incidence of malnutrition ) ) ) [field_reference_s_] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [value] => 13417150Collins, Joseph and Lappe, Frances M: World Hunger: twelve myths [format] => [safe_value] => 13417150<VM>Collins, Joseph and Lappe, Frances M: World Hunger: twelve myths ) [1] => stdClass Object ( [value] => 13462180Lawrence, Peter: World Recession and the Food Crisis in Africa [format] => [safe_value] => 13462180<VM>Lawrence, Peter: World Recession and the Food Crisis in Africa ) [2] => stdClass Object ( [value] => 13518640Walker, Peter: Famine Early Warning Systems: victims and destitution [format] => [safe_value] => 13518640<VM>Walker, Peter: Famine Early Warning Systems: victims and destitution ) [3] => stdClass Object ( [value] => 13566250Action Against Hunger: Geopolitics of Hunger, 2000-2001: Hunger and power [format] => [safe_value] => 13566250<VM>Action Against Hunger: Geopolitics of Hunger, 2000-2001: Hunger and power ) ) ) [field_organization_s_] => Array ( ) [field_human_development] => Array ( ) [field_value_s_] => Array ( ) [field_editorial_comments] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [value] => THIS IS WRITTEN UP AS A POLICY PROBLEMSEE STARVATION P 1875 AND HUNGER P0262 [format] => [safe_value] => THIS IS WRITTEN UP AS A POLICY PROBLEM<VM>SEE STARVATION P 1875 AND HUNGER P0262 ) ) ) [field_1a4n] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [value] => B0315 [format] => [safe_value] => B0315 ) ) ) [field_illustration] => Array ( ) [field_video] => Array ( ) [field_value_s_new] => Array ( ) [field_strategy_ies_new] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [target_id] => 196808 ) [1] => stdClass Object ( [target_id] => 200750 ) [2] => stdClass Object ( [target_id] => 197356 ) [3] => stdClass Object ( [target_id] => 198109 ) [4] => stdClass Object ( [target_id] => 197350 ) [5] => stdClass Object ( [target_id] => 197553 ) [6] => stdClass Object ( [target_id] => 222134 ) [7] => stdClass Object ( [target_id] => 197858 ) [8] => stdClass Object ( [target_id] => 218547 ) [9] => stdClass Object ( [target_id] => 197853 ) [10] => stdClass Object ( [target_id] => 197871 ) ) ) [field_illustration_automatic] => stdClass Object ( [und] => Array ( [0] => stdClass Object ( [fid] => 17190 [uid] => 490 [filename] => 534cacbe0de3813a0d300cc52b0ecfcb.jpg [uri] => public://source_files/images_automatic/534cacbe0de3813a0d300cc52b0ecfcb.jpg [filemime] => image/jpeg [filesize] => 130202 [status] => 1 [timestamp] => 1542760948 [type] => image [field_file_image_alt_text] => Array ( ) [field_file_image_title_text] => Array ( ) [rdf_mapping] => Array ( ) [metadata] => stdClass Object ( [height] => 995 [width] => 752 ) [height] => 406 [width] => 250 [alt] => [title] => ) ) ) [field_extra] => Array ( ) [field_content_quality] => Array ( ) [metatags] => stdClass Object ( [en] => stdClass Object ( [robots] => stdClass Object ( [value] => stdClass Object ( [0] => 0 [index] => 0 [follow] => 0 [noindex] => 0 [nofollow] => 0 [noarchive] => 0 [nosnippet] => 0 [noodp] => 0 [noydir] => 0 [noimageindex] => 0 [notranslate] => 0 ) ) ) ) [rdf_mapping] => stdClass Object ( [rdftype] => Array ( [0] => schema:Article [1] => sioc:Item [2] => foaf:Document ) [title] => stdClass Object ( [predicates] => Array ( [0] => schema:name ) ) [created] => stdClass Object ( [predicates] => Array ( [0] => dc:date [1] => dc:created ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [changed] => stdClass Object ( [predicates] => Array ( [0] => dc:modified ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [body] => stdClass Object ( [predicates] => Array ( [0] => content:encoded ) ) [uid] => stdClass Object ( [predicates] => Array ( [0] => sioc:has_creator ) [type] => rel ) [name] => stdClass Object ( [predicates] => Array ( [0] => schema:name ) ) [comment_count] => stdClass Object ( [predicates] => Array ( [0] => sioc:num_replies ) [datatype] => xsd:integer ) [last_activity] => stdClass Object ( [predicates] => Array ( [0] => sioc:last_activity_date ) [datatype] => xsd:dateTime [callback] => date_iso8601 ) [field_nature] => stdClass Object ( [predicates] => Array ( ) ) [field_background] => stdClass Object ( [predicates] => Array ( ) ) [field_incidence] => stdClass Object ( [predicates] => Array ( ) ) [field_claim] => stdClass Object ( [predicates] => Array ( ) ) [field_counter_claim] => stdClass Object ( [predicates] => Array ( ) ) [field_illustration] => stdClass Object ( [predicates] => Array ( [0] => schema:image ) [type] => rel ) [url] => stdClass Object ( [predicates] => Array ( [0] => schema:url ) [type] => rel ) [field_broader] => stdClass Object ( [predicates] => Array ( ) ) [field_narrower] => stdClass Object ( [predicates] => Array ( ) ) [field_related] => stdClass Object ( [predicates] => Array ( ) ) [field_aggravates] => stdClass Object ( [predicates] => Array ( ) ) [field_aggravated_by] => stdClass Object ( [predicates] => Array ( ) ) [field_reduces] => stdClass Object ( [predicates] => Array ( ) ) [field_reduced_by] => stdClass Object ( [predicates] => Array ( ) ) [field_name_s_] => stdClass Object ( [predicates] => Array ( [0] => schema:alternateName ) ) [field_test] => stdClass Object ( [predicates] => Array ( ) ) [field_type] => stdClass Object ( [predicates] => Array ( [0] => schema:subtype ) [type] => rel ) [field_subject_s_] => stdClass Object ( [predicates] => Array ( [0] => schema:category ) [type] => rel ) [field_tags] => stdClass Object ( [predicates] => Array ( ) [type] => rel ) [field_video] => stdClass Object ( [predicates] => Array ( [0] => schema:video ) ) [field_web_page_s_] => stdClass Object ( [predicates] => Array ( [0] => schema:url ) ) [field_value_s_new] => stdClass Object ( [predicates] => Array ( ) ) [field_strategy_ies_new] => stdClass Object ( [predicates] => Array ( ) ) [field_illustration_automatic] => stdClass Object ( [predicates] => Array ( [0] => schema:image ) [type] => rel ) [field_organization_s_] => stdClass Object ( [predicates] => Array ( ) ) [field_strategy_ies_] => stdClass Object ( [predicates] => Array ( ) ) [field_value_s_] => stdClass Object ( [predicates] => Array ( ) ) [field_human_development] => stdClass Object ( [predicates] => Array ( ) ) [field_reference_s_] => stdClass Object ( [predicates] => Array ( ) ) [field_extra] => stdClass Object ( [predicates] => Array ( [0] => schema:text ) ) [field_content_quality] => stdClass Object ( [predicates] => Array ( ) [type] => rel ) ) [path] => stdClass Object ( [pathauto] => 1 ) [name] => tomi [picture] => 0 [data] => a:1:{s:8:"gravatar";i:1;} [disqus] => stdClass Object ( [domain] => encyclopediaofworldproblems [status] => 1 [url] => https://edit.ewphp.org/en/problem/famine [title] => Famine [identifier] => node/132936 ) )