Last active
December 24, 2017 21:24
-
-
Save iign/4591679 to your computer and use it in GitHub Desktop.
Get your latest reviews from Letterboxd (letterboxd.com)
This file contains hidden or 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 require_once('letterboxd.php') ?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Letterboxd reviews</title> | |
<meta name="description" content="Letterboxd reviews demo"> | |
<meta name="author" content="ign <ignacio[at]ign.uy>"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="style.css"> | |
</head> | |
<body> | |
</body> | |
</html> | |
<?php if($reviews): ?> | |
<ul class="review-list"> | |
<?php foreach ($reviews->xpath('//item') as $r): ?> | |
<?php if(!strpos($r->link, '/list/')): ?> | |
<li class="film-item"> | |
<a href="<?php echo $r->link; ?>"> | |
<span class="overlay"></span> | |
<?php echo $r->description ?> | |
</a> | |
</li> | |
<?php endif ?> | |
<?php endforeach ?> | |
</ul> | |
<?php else: ?> | |
<span class="warning">User invalid</span> | |
<?php endif ?> |
This file contains hidden or 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 | |
namespace Letterboxd; | |
header('Content-Type: text/html; charset=UTF-8'); | |
define('USERNAME', 'iign'); // change this | |
define('ENDPOINT', 'http://letterboxd.com/' . USERNAME . '/rss'); | |
function get_http_response_code($url) { | |
$headers = get_headers($url); | |
return substr($headers[0], 9, 3); | |
} | |
if(get_http_response_code(ENDPOINT) != "404") { | |
$rss = file_get_contents(ENDPOINT); | |
$reviews = new \SimpleXMLElement($rss); | |
} | |
else { | |
$rss = false; | |
$reviews = false; | |
} |
This file contains hidden or 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
body{ | |
background:#14181C url("http://bullitt.cf2.letterboxd.com/static/img/content-bg.png") top repeat-x; | |
} | |
.review-list{ | |
list-style-type: none; | |
} | |
.review-list li{ | |
display: inline-block; | |
width: 150px; | |
height: 222px; | |
} | |
.review-list li p{ | |
padding: 0; | |
margin: 0; | |
-webkit-margin: 0; | |
} | |
.review-list li a{ | |
display: block; | |
margin: 0; | |
padding: 0; | |
position: relative; | |
text-decoration: none; | |
height: 100%; | |
} | |
.review-list li a:hover .overlay{ | |
border: 3px solid #72D147; | |
display: block; | |
position: absolute; | |
top: -3px; | |
left: -3px; | |
right: -3px; | |
bottom: -3px; | |
border-radius: 3px; | |
} | |
.review-list .film-item p:nth-of-type(2){ | |
display: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment