scripts/viaf_sameas_lookup.php
/**
 * Check VIAF for LoC links to update.  This script reads a CSV file of:
 *   ic_id, viafURL, locURL
 * and checks VIAF for the locURL's LoC ID.  If that ID exists in VIAF, 
 * then this script will query VIAF for additional SameAs links.  By default
 * it prints out the SameAs links to StdOut (terminal) and saves the new
 * and old VIAF IDs to the file viafloc_matching.csv, including a DRIFT flag
 * if the VIAF ID has changed for the given LoC ID. (That is, the LoC ID has
 * drifted from one VIAF cluster to another).
 *
 * For the full license, see the LICENSE file in the repository root
 *
 * @author Robbie Hott
 * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause
 * @copyright 2017 the Rector and Visitors of the University of Virginia, and
 *            the Regents of the University of California
 */
Check VIAF for LoC links to update.  This script reads a CSV file of:
ic_id, viafURL, locURL
and checks VIAF for the locURL's LoC ID.  If that ID exists in VIAF,
then this script will query VIAF for additional SameAs links.  By default
it prints out the SameAs links to StdOut (terminal) and saves the new
and old VIAF IDs to the file viafloc_matching.csv, including a DRIFT flag
if the VIAF ID has changed for the given LoC ID. (That is, the LoC ID has
drifted from one VIAF cluster to another).

For the full license, see the LICENSE file in the repository root


Check VIAF for LoC links to update . This script reads a CSV file of : ic_id viafURL locURL and checks VIAF for the locURL ' s LoC ID . If that ID exists in VIAF then this script will query VIAF for additional SameAs links . By default it prints out the SameAs links to StdOut ( terminal ) and saves the new and old VIAF IDs to the file viafloc_matching . csv including a DRIFT flag if the VIAF ID has changed for the given LoC ID . ( That is the LoC ID has drifted from one VIAF cluster to another ) . For the full license see the LICENSE file in the repository root
function viafGetRedirect($id) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://www.viaf.org/viaf/sourceID/LC|".$id);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);
    $lines = preg_split('/$\R?^/m', $response);
    $viafID = false;
    foreach ($lines as $line) {
        if (strstr($line, "Location:") !== false) {
            $viafID = trim(str_replace("Location: http://viaf.org/viaf/", "", $line));
            return $viafID;
        }
    }
    return $viafID;
}
function viafGetRedirect ( $ id ) { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , " http://www.viaf.org/viaf/sourceID/LC| " . $ id ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , 'GET' ) ; curl_setopt ( $ ch , CURLOPT_HEADER , true ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; $ response = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; $ lines = preg_split ( '/$\R?^/m' , $ response ) ; $ viafID = false ; foreach ( $ lines as $ line ) { if ( strstr ( $ line , " Location: " ) !== false ) { $ viafID = trim ( str_replace ( " Location: http://viaf.org/viaf/ " , " " , $ line ) ) ; return $ viafID ; } } return $ viafID ; }
Check VIAF for LoC links to update.
Check VIAF for LoC links to update .