scripts/viaf_dead_lookup.php
/**
 * Check VIAF for dead LoC links.  This script reads a CSV file of:
 *   ic_id, viafURL, locURL
 * and checks VIAF for the locURL's LoC ID.  If that ID does not exist
 * in VIAF, then this script will write that ic_id, LoC URL, and VIAF ID
 * to a file: viafloc_nomatch.csv. 
 *
 * 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 dead LoC links.  This script reads a CSV file of:
ic_id, viafURL, locURL
and checks VIAF for the locURL's LoC ID.  If that ID does not exist
in VIAF, then this script will write that ic_id, LoC URL, and VIAF ID
to a file: viafloc_nomatch.csv.

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


Check VIAF for dead LoC links . This script reads a CSV file of : ic_id viafURL locURL and checks VIAF for the locURL ' s LoC ID . If that ID does not exist in VIAF then this script will write that ic_id LoC URL and VIAF ID to a file : viafloc_nomatch . csv . 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 dead LoC links.
Check VIAF for dead LoC links .