自定义tagline为网易邮箱greetings


自定义tagline为网易邮箱greetings,api是从网上找的
修改wp-includes/option.php

最后加入获取问候语的函数(因为返回来是数组,做了个简单随机)

/**
* getrandom greetings form 163.com 
*/
function tagline_from_mail() {
        $URL = 'http://jy4-app.mail.163.com/jy4-app/xhr/mbox/greetings/get.do';
        $data = file_get_contents($URL);
        if($data === false){
                return '梦, I LOVE YOU';
        }
        //print_r($data);

        $json = json_decode(trim($data), true);
        //print_r($json);

        $greet_contents = $json['data']['contents'];
        //print_r($greet_contents);

        $index = rand(0, sizeof($greet_contents)-1);
        $greet_content = $greet_contents[$index];

        if(stripos($greet_content, '姓名,') !== FALSE){
                 return mb_substr($greet_content, 3, -1, "utf-8");
        }
        return $greet_content;
}

然后文件中调用函数

// If home is not set use siteurl.
if ( 'home' == $option && '' == $value )
    return get_option( 'siteurl' );
//在上面添加函数调用。修改tagline的值,blogdescription是数据库对应的tagline名
if ( 'blogdescription' == $option){
    $value = tagline_from_mail();
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: