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."\n";
10                 $sn = "序列号:".$content->sn."\n";
11                 $model = "设备名称:".$content->model."\n";
12                 $capacity = "设备容量:".$content->capacity."\n";
13                 $color = "设备颜色:".$content->color."\n";
14                 $number = $content->number;
15                 $identifier = $content->identifier;
16                 $network = $content->network;
17                 $activated = $content->activated;
18                 if($activated){
19                     $activated = "\n是否激活:已激活\n";
20                 }else{
21                     $activated = "\n是否激活:未激活\n";
22                 }
23                 $purchase = "激活日期:".$content->purchase->date."\n";
24                 $coverage = "保修状态:".$content->coverage."到期,";
25                 $daysleft = "剩余:".$content->daysleft."天\n";
26                 $support = $content->support;
27                 if($support=="expired"){
28                     $support="电话支持:已过期\n";
29                 }else{
30                     $support="电话支持:".$support."到期\n";
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 ("查询结果:\n".$sn.$ime.$model.$color.$capacity.$activated.$purchase.$coverage.$daysleft.$support.$applecare)->reply ();
44                 exit;
45                 }

 

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

上一篇:记微信第三方应用开发所遇到的坎


下一篇:微信授权登录