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

Posted 我的E家园

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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数据并在微信换行展示的主要内容,如果未能解决你的问题,请参考以下文章

如何解析 Twitter api 返回的 json 数据并在我的网页上使用?

解决动态生成的网页在微信浏览器中每次返回都会重新生成的问题

解决动态生成的网页在微信浏览器中每次返回都会重新生成的问题

PHP限制网页只能在微信内置浏览器中查看并显示

PHP限制网页只能在微信内置浏览器中查看并显示

php微信开发获取用户信息