• PHP获取网页返回的JSON数据并在微信换行展示


     1           $url ="http://japi.juhe.cn/joke/content/text.from?page=&pagesize=&key=c968d04ab0ea15e8f480b6c2d534804f";
     2                 $handle = fopen($url,"rb");
     3                 $content = "";
     4                 while (!feof($handle)) {
     5                 $content .= fread($handle, 600);
     6                 }
     7                 fclose($handle);
     8                 $content = json_decode($content)->data;;
     9                 $ime = "IMEI:".$content->imei."
    ";
    10                 $sn = "序列号:".$content->sn."
    ";
    11                 $model = "设备名称:".$content->model."
    ";
    12                 $capacity = "设备容量:".$content->capacity."
    ";
    13                 $color = "设备颜色:".$content->color."
    ";
    14                 $number = $content->number;
    15                 $identifier = $content->identifier;
    16                 $network = $content->network;
    17                 $activated = $content->activated;
    18                 if($activated){
    19                     $activated = "
    是否激活:已激活
    ";
    20                 }else{
    21                     $activated = "
    是否激活:未激活
    ";
    22                 }
    23                 $purchase = "激活日期:".$content->purchase->date."
    ";
    24                 $coverage = "保修状态:".$content->coverage."到期,";
    25                 $daysleft = "剩余:".$content->daysleft."天
    ";
    26                 $support = $content->support;
    27                 if($support=="expired"){
    28                     $support="电话支持:已过期
    ";
    29                 }else{
    30                     $support="电话支持:".$support."到期
    ";
    31                 }
    32                 $applecare = $content->applecare;
    33                 if($applecare){
    34                     $applecare = "是否官换机:是";
    35                 }else{
    36                     $applecare = "是否官换机:否";
    37                 }
    38                 $product = $content->product;
    39                 $start = $content->production->start;
    40                 $end = $content->production->end;
    41                 $origin = $content->production->origin;
    42             
    43                 $weObj->text ("查询结果:
    ".$sn.$ime.$model.$color.$capacity.$activated.$purchase.$coverage.$daysleft.$support.$applecare)->reply ();
    44                 exit;
    45                 }
  • 相关阅读:
    http 请求包含哪几个部分(请求行、请求头、请求体)
    BUG处理流程说明
    如何正确分析定位BUG
    如何定位bug是前端还是后端以及用的工具
    测试阶段划分为哪几个阶段?
    java实现一个简单的图书管理系统
    sql增、删、改、查基础封装类
    Ubuntu18.04 install sougou pinyin
    tensorboard网页打不开问题
    c++11 实现numpy argmax argmin
  • 原文地址:https://www.cnblogs.com/jeib/p/6879904.html
Copyright © 2020-2023  润新知