Cara Mendapatkan URL Gravatar dengan PHP
Lihat juga versi remake dengan JS.
<?php // post, email ok if($_SERVER['REQUEST_METHOD'] === 'POST') { header('Content-Type: text/plain'); if(!empty($_POST['str'])) { die('https://www.gravatar.com/avatar/' . md5($_POST['str'])); } } $get_sign = "<!--get-->"; echo $get_sign; ?><style> img { margin: 10px auto; border: 3px solid #ddd; } </style> <pre>Example, from official Gravatar (https://en.gravatar.com/site/implement/)</pre> <form method="post" target="post_target"> <input name="str" placeholder="gravatar email or username" style="width: 200px;" required/> <button type="submit">send</button> </form> <pre id="post_result"></pre> <iframe name="post_target" id="post_target" hidden></iframe> <script> (function() { var e = document.getElementById('post_target'); var r = document.getElementById('post_result'); e.onload = function() { var v = e.contentDocument.body.innerText; if(v === '' || v.indexOf('<?php echo $get_sign ?>') >= 0) return; // console.log(e.contentDocument.body.innerText); r.innerHTML = v + "\n<img src='" + v + "' style='display:none;' onload=\"this.style=''\"/>"; }; })(); </script>
Komentar
Posting Komentar
Komentar ...