本文整理汇总了PHP中Functions::get_hashed_response方法的典型用法代码示例。如果您正苦于以下问题:PHP Functions::get_hashed_response方法的具体用法?PHP Functions::get_hashed_response怎么用?PHP Functions::get_hashed_response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Functions
的用法示例。
在下文中一共展示了Functions::get_hashed_response方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_species_urls
function get_species_urls()
{
$species_urls = array();
if ($xml = Functions::get_hashed_response(DUTCH_SPECIES_LIST)) {
foreach ($xml->id as $id) {
print "\n {$id}";
$pos = stripos($id, "/");
$id = trim(substr($id, $pos + 1, strlen($id)));
print "\n {$id}";
$species_urls[] = TAXON_SERVICE . $id;
}
} else {
echo "\n\n Remote XML not available.";
}
return $species_urls;
}
示例2: fill_up_values
function fill_up_values($resource_path, $dataObjects)
{
if ($xml = Functions::get_hashed_response($resource_path, array('download_wait_time' => 1000000, 'timeout' => 600, 'download_attempts' => 5))) {
foreach ($xml->taxon as $taxon) {
foreach ($taxon->dataObject as $dataObject) {
$do_dcterms = $dataObject->children("http://purl.org/dc/terms/");
$do_dc = $dataObject->children("http://purl.org/dc/elements/1.1/");
if (@$dataObjects["{$do_dc->identifier}"]) {
$do_dcterms->bibliographicCitation = $dataObjects["{$do_dc->identifier}"]['agent'];
$dataObject->subject = $dataObjects["{$do_dc->identifier}"]['subject'];
$do_dc->description = $dataObjects["{$do_dc->identifier}"]['description'];
$do_dc->description->attributes('http://www.w3.org/XML/1998/namespace')->lang = $dataObjects["{$do_dc->identifier}"]['description_lang'];
}
}
}
return $xml->asXML();
}
}
示例3: scrape_species_page
public static function scrape_species_page($url, $ancestry)
{
$arr_acknowledgement = self::prepare_acknowledgement();
$arr_scraped = array();
$arr_photos = array();
$arr_sciname = array();
$ctr = 0;
print $url . "\n";
$xml = Functions::get_hashed_response($url);
print "taxa count = " . count($xml) . "\n";
foreach ($xml->url as $u) {
$u_video = $u->children("http://www.google.com/schemas/sitemap-video/1.0");
if ($url == "http://www.rkwalton.com/nhsskippers_videositemap.xml") {
$string = $u_video->video->description;
} else {
$string = $u_video->video->title;
}
$scientific_names = self::get_sciname($string, $url);
if (!$scientific_names) {
continue;
}
foreach ($scientific_names as $sciname) {
$exclude = array("Spiders In The Field", "Spiders and jumping Spiders", "Introduction to Solitary Wasps");
if (in_array($sciname, $exclude)) {
continue;
}
print "\n" . "[{$sciname}]";
$acknowledgement = self::get_acknowledgement($sciname, $arr_acknowledgement);
$description = "{$acknowledgement}<br>" . $u_video->video->description;
if ($u_video->video->description) {
$description .= "<br>Duration: " . $u_video->video->duration . " seconds";
}
//object agents
$agent = array();
$agent[] = array("role" => "author", "homepage" => "http://www.rkwalton.com", "name" => "Richard K. Walton");
$arr_photos["{$sciname}"][] = array("identifier" => $u_video->video->content_loc . "_" . str_replace(" ", "_", $sciname), "mediaURL" => str_ireplace(' ', '', $u_video->video->content_loc), "mimeType" => "video/mp4", "dataType" => "http://purl.org/dc/dcmitype/MovingImage", "description" => $description, "title" => $u_video->video->description, "location" => "", "dc_source" => $u->loc, "thumbnailURL" => $u_video->video->thumbnail_loc, "agent" => $agent);
$arr_sciname[$sciname] = 1;
}
}
foreach (array_keys($arr_sciname) as $sci) {
$arr_scraped[] = array("id" => $ctr, "kingdom" => $ancestry["kingdom"], "phylum" => $ancestry["phylum"], "class" => $ancestry["class"], "order" => @$ancestry["order"], "family" => @$ancestry["family"], "sciname" => $sci, "dc_source" => $ancestry["taxon_source_url"], "photos" => $arr_photos["{$sci}"]);
}
return $arr_scraped;
}
示例4: get_objects_info
private function get_objects_info($id, $scientific_name, $orig_sciname)
{
$total_objects = 0;
$id = str_ireplace("http://www.eol.org/pages/", "", $id);
$file = self::API_PAGES . $id . self::API_PAGES_PARAMS;
$text = 0;
$image = 0;
if ($xml = Functions::get_hashed_response($file, array('download_wait_time' => 1000000, 'timeout' => 240, 'download_attempts' => 5))) {
if ($xml->dataObject) {
foreach ($xml->dataObject as $object) {
if ($object->dataType == "http://purl.org/dc/dcmitype/StillImage") {
$image++;
} elseif ($object->dataType == "http://purl.org/dc/dcmitype/Text") {
$text++;
}
}
}
$total_objects = $image + $text;
}
return array($orig_sciname => 1, "orig_sciname" => $orig_sciname, "tc_id" => $id, "sciname" => $scientific_name, "text" => $text, "image" => $image, "total_objects" => $total_objects);
}
示例5: get_all_taxa
function get_all_taxa($resource_id)
{
$xml = Functions::get_hashed_response(CONTENT_RESOURCE_LOCAL_PATH . "35.xml");
$all_taxa = array();
$i = 0;
$total = count($xml->taxon);
foreach ($xml->taxon as $t) {
$i++;
$t_dwc = $t->children("http://rs.tdwg.org/dwc/dwcore/");
$t_dc = $t->children("http://purl.org/dc/elements/1.1/");
print "\n {$i} of {$total} " . $t_dc->identifier;
$url = str_replace('xxx', str_replace('STRI-fish-', '', $t_dc->identifier), $this->map_url);
print " [{$url}] ";
if ($file = fopen($url, "r")) {
if (stripos(fgets($file), "no_website_found")) {
print " - no map";
} else {
print " - with map";
$taxon_record["taxon"] = array("sciname" => $t_dwc->ScientificName, "family" => $t_dwc->Family, "kingdom" => '', "phylum" => '', "class" => '', "order" => '', "id" => str_replace('STRI-fish-', '', $t_dc->identifier), "mediaURL" => $url, "source" => $this->taxon_page . str_replace('STRI-fish-', '', $t_dc->identifier));
$taxon_record["dataobjects"] = array();
$arr = self::get_stri_taxa($taxon_record);
$page_taxa = $arr[0];
if ($page_taxa) {
$all_taxa = array_merge($all_taxa, $page_taxa);
}
unset($page_taxa);
}
} else {
debug(__CLASS__ . ":" . __LINE__ . ": Couldn't open file: " . $url);
}
}
$xml = \SchemaDocument::get_taxon_xml($all_taxa);
$resource_path = CONTENT_RESOURCE_LOCAL_PATH . $resource_id . ".xml";
if (!($OUT = fopen($resource_path, "w"))) {
debug(__CLASS__ . ":" . __LINE__ . ": Couldn't open file: " . $resource_path);
return;
}
fwrite($OUT, $xml);
fclose($OUT);
}
示例6: auth_get_token
public static function auth_get_token($frob)
{
$url = self::generate_rest_url("flickr.auth.getToken", array("frob" => $frob), 1);
return Functions::get_hashed_response($url);
}
示例7: get_synonyms
function get_synonyms($taxon_id)
{
$arr_synonyms = array();
$arr = array();
$xml = Functions::get_hashed_response(TROPICOS_API_SERVICE . $taxon_id . "/Synonyms?format=xml&apikey=" . TROPICOS_API_KEY, array('timeout' => 4800, 'download_attempts' => 5));
foreach ($xml->Synonym as $syn) {
$synonym = trim($syn->SynonymName->ScientificNameWithAuthors);
$arr[$synonym] = "";
}
foreach (array_keys($arr) as $synonym) {
if ($synonym) {
$arr_synonyms[] = array("synonym" => $synonym, "relationship" => "synonym");
}
}
return $arr_synonyms;
}
示例8: get_mediaURL
public function get_mediaURL($url)
{
if (!($xml = Functions::get_hashed_response($url))) {
// url not accessible
return;
}
foreach ($xml->Items->I as $rec) {
$mediaURL = str_ireplace('.dzi', '_files/thumb.jpg', @$rec["Source"]);
}
return $mediaURL;
}
示例9: get_id_list
function get_id_list()
{
$urls = array();
// $urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2011_small.xml"; //for debug
$urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2007.xml";
$urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2008.xml";
$urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2009.xml";
$urls[] = DOC_ROOT . "/update_resources/connectors/files/WORMS/2010.xml";
$urls[] = "http://dl.dropbox.com/u/7597512/WORMS/2011.xml";
$urls[] = "http://dl.dropbox.com/u/7597512/WORMS/2012.xml";
//append year (the current year) and onwards
$urls = self::generate_url_list($urls);
/* debug
$r = array();
$r[] = $urls[0];
$urls = $r;
*/
echo "\n URLs = " . sizeof($urls) . "\n";
print_r($urls);
$ids = array();
$file_ctr = 0;
foreach ($urls as $url) {
echo "\n Processing: {$url} \n";
if ($xml = Functions::get_hashed_response($url, array('timeout' => 240, 'download_attempts' => 5))) {
foreach ($xml->taxdetail as $taxdetail) {
$id = @$taxdetail["id"];
$ids[] = $id;
}
}
sleep(30);
//debug orig 30
}
//delete temp XML files
Functions::delete_temp_files($this->TEMP_FILE_PATH . "xmlcontent_", "xml");
$ids = array_unique($ids);
echo "\n total ids: " . sizeof($ids);
echo "\n" . sizeof($urls) . " URLs | taxid count = " . sizeof($ids) . "\n";
/* debug
$r = array();
$r[] = $ids[0];
$r[] = $ids[1];
$r[] = $ids[2];
$r[] = $ids[3];
$r[] = $ids[4];
$r[] = $ids[5];
$r[] = $ids[6];
$r[] = $ids[7];
$r[] = $ids[8];
$r[] = $ids[9];
$r[] = $ids[10];
$r[] = $ids[11];
$r[] = $ids[12];
$r[] = $ids[13];
$r[] = $ids[14];
$r[] = $ids[15];
$r[] = $ids[16];
$r[] = $ids[17];
$r[] = $ids[18];
$r[] = $ids[19];
$ids = $r;
*/
// $ids = array(); $ids[] = 246718;//9182;//243944;
/*debug: to be used when searching for an id
foreach(array(582008, 582009, 582010) as $id)
{
if(in_array($id, $ids)) echo "\n $id found";
else echo "\n $id not found";
}
*/
return $ids;
}
示例10: count
$total_image_ids = count($image_ids);
print "\n count of image ID's = {$total_image_ids}";
if ($total_image_ids == 0) {
exit("\n Program will terminate. MorphBank service not ready.");
}
/* loop through image ids */
$k = 0;
foreach ($image_ids as $image_id) {
$k++;
if ($k % 5000 == 0) {
sleep(60);
}
// might need this as MorphBank service chokes on continues request. They have not yet solved this problem. Service still chokes.
print "\n {$image_id} [{$k} of {$total_image_ids}]";
print "\n " . $details_method_prefix . $image_id . " \n";
if (!($xml = Functions::get_hashed_response($details_method_prefix . $image_id))) {
continue;
}
foreach ($xml->object as $object) {
if (!$object["type"] == "Image") {
break;
}
$dwc = $object->children("http://rs.tdwg.org/dwc/dwcore/");
$dwc_Kingdom = trim($dwc->Kingdom);
$dwc_Phylum = trim($dwc->Phylum);
$dwc_Class = trim($dwc->Class);
$dwc_Order = trim($dwc->Order);
$dwc_Family = trim($dwc->Family);
$dwc_Genus = trim($dwc->Genus);
$dwc_ScientificName = trim($dwc->ScientificName);
$taxon_identifier = str_replace(" ", "_", $dwc_ScientificName);
示例11: get_objects_info
function get_objects_info($id, $sciname, $orig_sciname)
{
$sciname_4color = "";
$total_objects = 0;
$id = str_ireplace("http://www.eol.org/pages/", "", $id);
$file = self::API_PAGES . $id . self::API_PAGES_PARAMS;
$text = 0;
$image = 0;
if ($xml = Functions::get_hashed_response($file)) {
$score = $xml->taxonConcept->additionalInformation->richness_score;
if ($xml->dataObject) {
foreach ($xml->dataObject as $object) {
if ($object->dataType == "http://purl.org/dc/dcmitype/StillImage") {
$image++;
} elseif ($object->dataType == "http://purl.org/dc/dcmitype/Text") {
$text++;
}
}
}
$total_objects = $image + $text;
}
if ($orig_sciname != $sciname_4color) {
$sciname_4color = $sciname;
}
return array($orig_sciname => 1, "orig_sciname" => $orig_sciname, "tc_id" => $id, "sciname" => $sciname, "text" => $text, "image" => $image, "total_objects" => $total_objects, "score" => $score, "last_curated" => '', "overview_word_count" => self::get_word_count($id, "brief summary"), "general_description_word_count" => self::get_word_count($id, "comprehensive description"));
}
示例12: get_inotaxa_taxa
public static function get_inotaxa_taxa($url, $debug = NULL)
{
global $taxon_identifier;
global $taxon_parameters;
global $used_taxa;
global $taxon;
global $rightsHolder;
/*
TaxonomicPublication
IndividualPublication
Metadata
PublicationFrontMatter
PublicationTaxonomicMatter Heading="none"
TaxonTreatment
TreatmentAuthors
TreatmentAuthorAtomised
TreatmentDate
TaxonHeading
RankDesignation
TaxonHeadingName
AlternateUsedInWork
TaxonName
GenusName
TaxonCitationGroup
Descriptions
DistributionAndOrSpecimenCitations
Discussions
PublicationTaxonomicMatter Heading="Supplement"
PublicationBackMatter
OtherNamesIndex
*/
$schema_taxa = array();
///////////////////////////////
$used_taxa = array();
/* If this is outside the main loop then, data objects from a single species
coming from 2 INOTAXA providers will be placed in 1 <taxon> element.
If this is inside the loop then, there will be 2 <taxon> elements for 2 same species from 2 BCA providers.
*/
///////////////////////////////
$xml = Functions::get_hashed_response($url);
if (!($xml = Functions::get_hashed_response($url))) {
print "\n <a href='{$url}'>{$url}</a> not accessible";
return;
}
$i = 0;
$sciname = array();
//just for debugging
$hierarchy = array();
$rightsHolder = trim(strip_tags($xml->IndividualPublication->PublicationFrontMatter->SeriesTitle->Title->asXML()));
$main_count = 0;
foreach ($xml->IndividualPublication as $main) {
$main_count++;
//print"<pre>";print_r($main);print"</pre>";
$ptm_count = 0;
foreach ($main->PublicationTaxonomicMatter as $ptm) {
$ptm_count++;
$tt_count = 0;
foreach ($ptm->TaxonTreatment as $tt) {
$tt_count++;
//print"\n $main_count of " . count($xml->IndividualPublication);
//print" | $ptm_count of " . count($main->PublicationTaxonomicMatter);
//print" | $tt_count of " . count($ptm->TaxonTreatment);
$taxon_identifier = @$tt["TaxonID"];
$dwc_ScientificName = trim($tt->TaxonHeading->TaxonHeadingName->AlternateUsedInWork->TaxonName);
if ($debug) {
if (in_array($dwc_ScientificName, array("Attelabus ater"))) {
} else {
continue;
}
/*
Thecesternus affinis - Context in original:
Thecesternus humeralis - separate or put citation
*/
/*
if(in_array($dwc_ScientificName, array( "Thecesternus humeralis",
"Ophryastes ovipennis",
"Anypotactus",
"Ophryastes bituberosus",
"Aphrastus angularis",
"Attelabus ater"
))){}
else continue;
*/
//debug
}
$rank = $tt->TaxonHeading->RankDesignation;
$i++;
$sciname["{$dwc_ScientificName}"] = $dwc_ScientificName;
$taxon = str_replace(" ", "_", $dwc_ScientificName);
if (@$used_taxa[$taxon]) {
$taxon_parameters = $used_taxa[$taxon];
} else {
$taxon_parameters = array();
//start get hierarchy
foreach ($tt->TaxonHierarchyAbove as $tha) {
$ranks = array("kingdom", "phylum", "class", "order", "family", "genus");
$rank = $tha->RankDesignation;
if (in_array($rank, $ranks)) {
$taxon_parameters["{$rank}"] = $tha->TaxonHeadingName->AlternateUsedInWork->TaxonName;
$hierarchy["{$rank}"] = $tha->TaxonHeadingName->AlternateUsedInWork->TaxonName;
//.........这里部分代码省略.........
示例13: get_taxon_details
function get_taxon_details($id)
{
$languages = array("en" => self::ENGLISH_DIR, "nl" => self::DUTCH_DIR);
$description = "";
$title = "";
$identifier = "";
$mediaURL = "";
$mimeType = "";
$rightsHolder = "";
$source = "";
$texts = array();
$objects = array();
$text_rightsHolder = "";
foreach ($languages as $language => $dir) {
debug("\n {$language} - {$dir} \n");
if ($language == "nl") {
if (substr($description, strlen($description) - 2, 2) == ". ") {
$description = substr($description, 0, strlen($description) - 2) . "; ";
}
if (substr($title, strlen($title) - 2, 2) == ". ") {
$title = substr($title, 0, strlen($title) - 2) . "; ";
}
}
$xml_file = self::ECOMARE_SOURCE_DIR . "/{$dir}/" . $id . ".xml";
debug("\n Accessing: {$xml_file} \n");
if ($xml = Functions::get_hashed_response($xml_file, array('download_wait_time' => 1000000, 'timeout' => 600, 'download_attempts' => 2, 'delay_in_minutes' => 2))) {
debug(" - OK ");
foreach ($xml->content_item as $item) {
if ($item->type == 9) {
$source_url = str_ireplace("L=0", "L=2", $xml->subject_setup->source_url);
if (trim($item->file_name) != "") {
$description .= $item->image_description != '' ? "" . $item->image_description . ". " : '';
$title .= $item->header != '' ? "" . $item->header . ". " : '';
$identifier = "img_" . $item->uid;
$mediaURL = self::ECOMARE_DOMAIN . $item->file_path . $item->file_name;
$mimeType = Functions::get_mimetype($item->file_name);
$rightsHolder = $item->image_copyright;
$source = $source_url;
}
if (!in_array($item->bodytext, $texts)) {
$objects[] = array("identifier" => $item->uid, "mediaURL" => '', "mimeType" => 'text/html', "dataType" => 'http://purl.org/dc/dcmitype/Text', "rightsHolder" => '', "title" => '', "description" => strip_tags($item->bodytext), "source" => $source_url, "license" => "http://creativecommons.org/licenses/by-nc/3.0/", "subject" => "http://rs.tdwg.org/ontology/voc/SPMInfoItems#TaxonBiology", "language" => $language);
$texts[] = $item->bodytext;
}
} elseif ($item->type == 10) {
$text_rightsHolder = strip_tags($item->bodytext);
}
}
}
}
// language loop
$objects[] = array("identifier" => $identifier, "mediaURL" => $mediaURL, "mimeType" => $mimeType, "dataType" => 'http://purl.org/dc/dcmitype/StillImage', "rightsHolder" => $rightsHolder, "title" => $title, "description" => strip_tags($description), "source" => $source, "license" => "http://creativecommons.org/licenses/by-nc/3.0/", "subject" => "", "language" => "en");
$i = 0;
foreach ($objects as $object) {
if ($object["mimeType"] == 'text/html') {
$objects[$i]["rightsHolder"] = $text_rightsHolder;
}
$i++;
}
return $objects;
}
示例14: get_main_id_list
function get_main_id_list()
{
$urls[] = "http://www.habitas.org.uk/marinelife/specieslist_xml.asp";
print "\n URLs = " . sizeof($urls) . "\n";
$no_of_urls = sizeof($urls);
$arr = array();
foreach ($urls as $url) {
$j = 0;
if ($xml = Functions::get_hashed_response($url)) {
foreach ($xml->id as $source_url) {
print "\n --> " . $source_url;
@($arr["{$source_url}"] = true);
$j++;
}
print "\n";
}
print "\n" . " no. of urls: " . $no_of_urls . " URLs | taxid count = " . $j . "\n";
}
print " \n";
$arr = array_keys($arr);
return $arr;
}
示例15: get_upload_videos_from_usernames
public function get_upload_videos_from_usernames($usernames)
{
$max_results = 50;
$user_video_ids = array();
foreach ($usernames as $username) {
debug("\n Getting video list for {$username}...");
$start_index = 1;
while (true) {
$url = YOUTUBE_API . "/users/" . $username . "/uploads?" . "start-index={$start_index}&max-results={$max_results}";
if ($xml = Functions::get_hashed_response($url, array('download_wait_time' => 3000000, 'timeout' => 240, 'download_attempts' => 2, 'delay_in_minutes' => 5))) {
if ($xml->entry) {
foreach ($xml->entry as $entry) {
$user_video_pathinfo = pathinfo($entry->id);
$user_video_ids[$username][] = $user_video_pathinfo['basename'];
}
} else {
break;
}
$start_index += $max_results;
} else {
break;
}
}
}
return $user_video_ids;
}