使用PHP格式化JSON数据 [英] Formatting JSON Data using PHP
问题描述
我有以下代码:
<?php
$ids = 'ids=com.hugogames.hugotrollwars';
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $ids
)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://play.google.com/store/xhr/getdoc', false,
$context);
$convert = explode("\n", $result);
基本上是从Playstore提取权限并将其显示为字符串.我遇到的问题是删除不需要的数据(图像链接,描述),仅显示权限和权限描述.我尝试将json_decode函数与php结合使用,但返回NULL.
Basically its pulling permissions from the Playstore and displaying it as a string. The issue I am having is removing the un needed data (image links, description) and only show the permissions and the permissions description. I tried using the json_decode function with php and it returned NULL.
我有什么想念的吗?
任何帮助将不胜感激!
推荐答案
$ result是无效的json. Google Play API使用的是protobuf变体.
$result is not valid json. Google Play API is using a protobuf variant.
http://www.segmentationfault.fr /publications/reversing-google-play-and-micro-protobuf-applications/
还有一些与Google Play交流的PHP库.
There are also php libraries to talk to google play.
https://github.com/splitfeed/android-market-api-php
https://github.com/thetutlage/Google-Play-Store-API
这篇关于使用PHP格式化JSON数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!