ÔÚÆÀÂÛÕßÊäÈëÓÊÏäºó£¬Òì²½»ñµÃÆÀÂÛÕßµÄÍ·Ïñ²¢ÏÔʾ³öÀ´£¬¸öÈ˸оõÕâ¸ö¹¦ÄÜËä²»ÄܸøÓû§ÌåÑé´øÀ´¶à´óµÄÌáÉý£¬Ò²²»ËãÊÇÒ»¸öʵÓõŦÄÜ£¬µ«ÖÁÉÙºÜìÅ£¬¿´µ½ÓеÄÍøÕ¾ÓÐÌí¼ÓÕâ¸ö¹¦ÄÜ£¬ÎÒÒ²²»¸Ê¼ÅįËùÒÔҲдÁ˸ö½Å±¾£¬Ã»ÓÐʱ¼ä×ö·â×°£¬ËùÒÔÖ±½ÓÉÏÔÀíºÍ´úÂë¡£
Òì²½¶¯Ì¬µ÷ÓÃÍ·ÏñÔÀí
òËƺܶಽÖ裬ÆäʵºÜ¼òµ¥£¬ÎÒÃÇÖ»Òª½«×Ô¼ºµÄÖ÷ÌâÉÔ×÷Ð޸ľͿÉÒÔµ½´ïЧ¹û¡£
¼òµ¥¹¦ÄܽØͼ£º
ʵÏÖ
¹¦ÄÜ´úÂ룺JavaScript
ÒÔÏ´úÂëÐ輯³É JQuery ¿ò¼ÜÖС£
apiurl ±äÁ¿ÎªÄãµÄphp api ½Ó¿ÚÎļþµØÖ·£¬Îļþ´úÂëÏÂÃæÓС£
¹¦ÄÜÖ÷Òª¼¯ÖÐÔÚemailÊäÈë¿òʧȥ½¹µãµÄ¶¯×÷ÉÏ¡£
function getAvatar(authorEmail) {//»ñµÃÍ·Ïñ´úÂë·â×°º¯Êý var nowtime = Math.round(new Date().getTime() / 1000); $.get(apiurl, { action : "get_avatar", email : authorEmail, t : nowtime }, function(data) { $('#get-avatar-img').fadeOut('slow', function() { $('#get-avatar-img').html(data).fadeIn(); }) }); } var avatarhtml = '<div>'; avatarhtml += '</div>'; $('#respond').append(avatarhtml);//Ìí¼ÓÍ·ÏñHTML if($('#email').val().length > 1) getAvatar($('#email').val());//»ñµÃÓÊÏäµØÖ· $('#email').focusout(function() {//emailÊäÈë¿òʧȥ½¹µã°ó¶¨µÄ¶¯×÷ var authorEmail = $('#email').val(); var pattern = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/; var flag = pattern.test(authorEmail); if(flag) { $('#get-avatar-img').html('ÔØÈëÍ·ÏñÖÐ').fadeIn('fast'); getAvatar(authorEmail); } else { alert('ÇëÊäÈëÕýÈ·ÓÊÏäµØÖ·'); } })
¹¦ÄÜ´úÂ룺PHP
ºǫ́ÏìÓ¦´úÂ룬ÔÚÕâÀïÎÒÓÃÁËÒ»¸öµ¥¶ÀµÄÒ³ÃæÎļþÀ´×öÏìÓ¦£¬
ÕâÑù×öµÄºÃ´¦ÊDz»Óôò¿ªÃ¿¸öÒ³ÃæµÄʱºò¶¼È¥µ÷ÓÃÕⲿ·Ö´úÂ룬
Ö»ÊÇÔÚ×ö³öÇëÇóʱ²ÅÈ¥ÏìÓ¦£¬ÕâÑù×ö¿ÉÒÔÍêÈ«ÞðÆúÖ÷ÌâµÄÏòºó¼æÈݹËÂÇ¡£
µ±È»ÄãÒ²¿ÉÒÔ½«ÏìÓ¦º¯Êý¹ÒÔص½wpµÄhookÉÏ¡£
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : false ; if($action){//ÁôÏÂÒÔºóÌí¼Ó¹¦ÄܵĿռ䣬Ä㶮µÄ¡£ switch ($action) { case 'get_avatar': $email = isset($_REQUEST['email']) ? $_REQUEST['email']: false ; if($email){ echo get_avatar($email,60); } break; default: echo "ÇëÇóÄÚÈݲ»³ä·Ö"; break; } }
×ܽá
So¡¡. ºÜ¼òµ¥°É£¿
ÇëÇó-> ÏìÓ¦ -> Ìí¼Ó ×ܹ²Èý²½Çú¡£
µ±È»£¬ÕâÀïΪÁËÔöÇ¿Âß¼ÐÔ£¬Í»³öÌõÀí£¬°ÑһЩ±ØÒªµÄÊý¾Ý¹ýÂË£¬
»¹ÓÐһЩ´íÎóÅжϣ¬ÕâЩ¾ÍËãÊÇÁô×÷˼¿¼°É¡£
¡¡