Last active
November 2, 2018 18:32
-
-
Save emasters/f69675b330934ded7441c8c32f1749fa to your computer and use it in GitHub Desktop.
First swipe at using the CAP API to retreive a the full text of a case.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Working with Harvard's CAP API | |
* | |
*/ | |
$authorization = "Token your-API-key-here"; | |
$cite = "309 F.2d 912"; | |
$full_case = "true"; | |
$body_format = "html"; | |
$params = array( | |
'cite' => $cite, | |
'full_case' => $full_case, | |
'body_format' => $body_format, | |
); | |
$query = http_build_query($params); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, "https://api.case.law/v1/cases/?$query"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Authorization: '.$authorization, | |
) | |
); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
//echo "<pre>".$result."</pre><hr>"; | |
$capresult = (json_decode($result,true)); | |
//print("<pre>".print_r($capresult,true)."</pre>"); | |
echo $capresult['results'][0]['casebody']['data']; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get a n API key you'll need to create an account on case.law and then visit https://case.law/user/details.