https://open.taobao.com/doc.htm?spm=a219a.7386653.0.0.120c669apt4vTq&docId=1&docType=15&apiName=taobao.tmc.messages.consume
订单content.order_id是18位数据,在php转换成json数组时,其值会变化,最后3位会替换成其他值(没规律)。
解决办法:
将order_id串替换成字符串再转换成json。
//!! $content为stdObject,要转换为array $content = json_decode(json_encode($content),true); $foo = $content['messages']['tmc_message']; foreach($foo as $idx=>$item){ $bar = preg_replace('/\\"order_id\\":(\d+),/','"order_id":"\1",',$item['content']); $foo[$idx]['content'] = json_decode($bar,true); }
转载于:https://my.oschina.net/swingcoder/blog/3098389