Skip to content

Instantly share code, notes, and snippets.

@librarywebchic
librarywebchic / auth_code_gettoken.php
Created October 7, 2019 16:52
Obtain an Access Token with an Authorization code
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use League\OAuth2\Client\OptionProvider\HttpBasicAuthOptionProvider;
use League\OAuth2\Client\Provider\GenericProvider;
$setup_options = [
'clientId' => WSKEY,
'clientSecret' => SECRET,
'redirectUri' => 'http://localhost:8080/'
'urlAuthorize' => 'https://oauth.oclc.org/auth',
use OCLC\Auth\WSKey;
use OCLC\Auth\AccessToken;
use OCLC\User;
$key = 'api-key';
$secret = 'api-key-secret';
$services = array('SCIM');
$user = new User('128807', 'principalID', 'principalIDNS');
$options = array('services' => $services);
@librarywebchic
librarywebchic / changeLocation.js
Created October 30, 2018 17:57
Sample Code Change Location information
"use strict";
const nodeauth = require("nodeauth");
const axios = require("axios");
const xpath = require('xpath');
const dom = require('xmldom').DOMParser;
const serializer = require('xmldom').XMLSerializer;
const builder = require('xmlbuilder');
const serviceUrl = 'circ.sd00.worldcat.org/LHR';
@librarywebchic
librarywebchic / wcdAPIExampleNodeJS.js
Created January 12, 2018 02:43
Call to WC DIscovery API nodeJS
var WSKey = require('oclc-wskey')
const axios = require("axios");
var https = require('https')
var url = require('url')
var me = { principalID: 'principalID', principalIDNS: 'principalIDNS' }
var key = new WSKey('key', 'secret', me)
var request_url = 'https://authn.sd00.worldcat.org/oauth2/accessToken?grant_type=client_credentials&authenticatingInstitutionId=128807&contextInstitutionId=128807&scope=WorldCatDiscoveryAPI';
var authorization = key.HMACSignature('POST', request_url)
var config = {
@librarywebchic
librarywebchic / .gitignore
Last active May 19, 2017 16:51
Example of calling NCIP service in PHP
/vendor/
/.project
/config.yml
{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"relators": "http://id.loc.gov/vocabulary/relators/",
"schema": "http://schema.org/",
"viaf": "http://viaf.org/viaf/",
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"@graph": [
@librarywebchic
librarywebchic / Mashathon_US_2011
Created April 1, 2011 17:51
Hands-on Code example from Mashathon 2011
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Find Books Related to where you are</title>
<script type="text/javascript" language="JavaScript" src="../script_libraries/demo_config.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi?key=yourkey"></script>
<script type="text/javascript">
google.load("maps", "3",{"other_params":"sensor=true"});
google.load("jquery", "1.4.4");
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Find Books Related to where you are</title>
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAtsEsZKvTMrabC2Wd7XITJhR_DDkFHwL5BSWO8LemKnbXoiPGUBSIGXXVgNcF9XgCIlUajQ7GxO7c2w"></script>
<script type="text/javascript">
google.load("maps", "3",{"other_params":"sensor=true"});
google.load("jquery", "1.4.4");
google.load("jqueryui", "1.8.7");