微信公众平台开发(60)每日英语

微信公众平台开发 微信公众平台开发模式 企业微信公众平台 每日英语 每日一句 听力 阅读 作文 词汇 
作者:方倍工作室 
地址:http://www.cnblogs.com/txw1958/p/weixin-60-english.html 

 

 

每日一句&每日一听查询

使用金山词霸开放平台提供的接口:

接口地址: http://open.iciba.com/dsapi/

返回内容:

{
    "sid": "700",
    "tts": "http://news.iciba.com/admin/tts/2013-11-04.mp3",
    "content": "The only person you should try to be better than, is who you were yesterday.",
    "note": "你唯一应该超越的人,是昨天的自己。",
    "translation": "词霸小编:很多时候,我们最大的对手就是自己,战胜自己就能战胜一切!加油!",
    "picture": "http://cdn.iciba.com/news/word/2013-11-04.jpg",
    "picture2": "http://cdn.iciba.com/news/word/big_2013-11-04b.jpg",
    "caption": "词霸每日一句",
    "dateline": "2013-11-04",
    "s_pv": "2780",
    "sp_pv": "566"
}

词霸每日一句If you are not learning something new every day, you are wasting away days of your life.

If you are not learning something new every day, you are wasting away days of your life. 
如果每天不学点新的东西,就是在浪费生命。
 又是一年开学季,让自己每天都有新收获吧!加油,不为别人,只为自己!
 

解析代码如下:

function getDailyEnglishInfo($keyword)
{
    $url = "http://open.iciba.com/dsapi/";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);
    $output = str_replace("%", "%%", $output); 
    $result = json_decode($output, true);
    
$english = array(); 
$english[] = array("Title" =>"双语 ".$result["dateline"], "Description"=>$result["content"]."\n".$result["note"]."\n\n".str_replace("词霸小编:", "", $result["translation"]."\n\n回复“听力”获取本文听力资料"), "PicUrl" =>$result["picture"], "Url" =>"");
    return $english;
}

 

实现效果如下:

 

 

posted @ 2013-09-01 12:13  方倍工作室  阅读(6984)  评论(1编辑  收藏