zoukankan      html  css  js  c++  java
  • 微信公众平台开发(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"]."
    ".$result["note"]."
    
    ".str_replace("词霸小编:", "", $result["translation"]."
    
    回复“听力”获取本文听力资料"), "PicUrl" =>$result["picture"], "Url" =>"");
        return $english;
    }

    实现效果如下:

  • 相关阅读:
    Shell 编程基础之 Until 练习
    Shell 编程基础之 While 练习
    Shell 编程基础之 For 练习
    Shell 编程基础之 If 练习
    Kafka 0.8 Controller设计机制和状态变化
    5 Kafka 应用问题经验积累
    3 Kafka两个版本在Zookeeper的元数据存储
    Broker流量均衡 prefer reassign
    Kafka 0.8 Consumer Rebalance
    2 Kafka Broker
  • 原文地址:https://www.cnblogs.com/txw1958/p/weixin-60-english.html
Copyright © 2011-2022 走看看