微信公眾平台開發(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;
}

 

實現效果如下:

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM