微 每日一句&每日一听查询
使用金山词霸开放平台提供的接口:
接口地址: 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.
如果每天不学点新的东西,就是在浪费生命。
又是一年开学季,让自己每天都有新收获吧!加油,不为别人,只为自己!
解析代码如下:
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"]."nn".str_replace("词霸小编:", "", $result["translation"]."nn回复“听力”获取本文听力资料"), "PicUrl" =>$result["picture"], "Url" =>"");
return $english;
}
实现效果如下:






