Skip to content

Commit 289220e

Browse files
authored
list similar apps, move ReadMe content to wiki #13
Merge pull request #13 from IzzySoft/devel
2 parents 5018f60 + 702861b commit 289220e

File tree

2 files changed

+47
-173
lines changed

2 files changed

+47
-173
lines changed

README.md

Lines changed: 24 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ Tiny script to crawl information of a specific application in the Google play/st
44

55
## PHP GooglePlay Methods
66

7-
- parse
8-
- parseSearch
9-
- parseCategory
10-
- parseCategories
11-
- parseApplication
12-
- parsePerms
7+
- `parse`: mostly used internally – but can be used to parse any URL or text for valid Play Store app links and return their packageNames
8+
- `parseSearch`: search for apps by given terms
9+
- `parseSimilar`: search for what Google Play considers apps similar to the one specified
10+
- `parseCategory`: list apps from a specified category
11+
- `parseCategories`: list available categories
12+
- `parseApplication`: get details for a specific app
13+
- `parsePerms`: retrieve permissions requested by a specific app
14+
1315

1416
## Using PHP GooglePlay
1517

@@ -21,8 +23,7 @@ $google = new GooglePlay();
2123
$app=$google->parseApplication("com.bezapps.flowdiademo");
2224
print_r($app);
2325

24-
25-
$app=$google->parseApplication("com.bezapps.flowdiademo");
26+
$app=$google->parseSimilar("com.bezapps.flowdiademo");
2627
print_r($app);
2728

2829
$apps=$google->parseSearch("telegram");
@@ -33,171 +34,25 @@ print_r($apps);
3334
?>
3435
```
3536

36-
Read more at [wiki](https://github.com/BaseMax/GooglePlayWebServiceAPI/wiki).
37-
38-
#### How to action as a crawler and find more applications?
39-
40-
https://github.com/BaseMax/GooglePlayWebServiceAPI/wiki/Search
41-
42-
### Application Structure
43-
44-
- packageName
45-
- name
46-
- developer
47-
- category
48-
- type (game, app)
49-
- description
50-
- icon
51-
- images
52-
- updated
53-
- version
54-
- require
55-
- install
56-
- age
57-
- rating
58-
- votes
59-
- price
60-
- size
61-
- success (1 if data was retrieved, 0 otherwise)
62-
- message (only with success==0, telling you what failed)
63-
64-
If retrieving data failed, the returned array will only hold the keys `success` and `message`. If it succeeded, there won't be a `message` key.
65-
66-
67-
### Output Google Play structure
68-
69-
Crawl from: https://play.google.com/store/apps/details?id=com.bezapps.flowdiademo&hl=en_US&gl=US
70-
71-
```
72-
Array
73-
(
74-
[packageName] => com.bezapps.flowdiademo
75-
[name] => Flowdia Diagrams Lite
76-
[developer] => BEZAPPS
77-
[category] => Productivity
78-
[type] => app
79-
[description] => Flowdia is an easy to use flow diagram tool that can be used to quickly create professional quality flowcharts, mind maps, BPMN, network and server layouts, Cisco network, Rack diagram, UML activity, business process and process flow diagrams. <br><br>The app is designed with ease of use in mind. You can quickly connect flowchart shapes by simply selecting the start and end connection points and quickly add new lanes to a swimlane diagram or new sub-topics to a mind map diagram by using &quot;+&quot; button from the selected swimlane or mind map shape menu. The mind map sub-topics are automatically positioned on the page but can be easily moved as required. <br><br>Flowdia supports export of the diagram / flowchart to PNG, JPG, PDF and SVG formats.You can view exported SVG files in Microsoft Visio.<br><br>You can import custom PNG and JPG images.<br><br>The following diagrams can be created using Flowdia:<br><br>- Flowchart<br>- Swimlanes<br>- Mind Maps<br>- BPMN<br>- Network Diagram<br>- Cisco Network Diagram<br>- Server Layout Diagram<br>- Rack Diagram<br>- UML Activity Diagram<br>- Business Process Diagram<br>- Process Flow<br>- Chevron Diagram<br><br>You can quickly select and change BPMN activity, event and gateway types by using the special shape selector available to all BPMN shapes.<br><br>The flowchart shapes in this tool are not images can be re-sized without loosing quality. You can customize the look of the shapes by applying background color and also change the font color and size of the text.<br><br>**NOTE: Lite version of Flowdia is restricted to:<br>- 4 files.<br>- 1 page per diagram.<br>- Cannot remove or duplicate pages.<br>- Image and PDF exports with watermark
80-
[icon] => https://lh3.googleusercontent.com/Ad85EXrQ1CwPA7Nyf9j_jYtgD4V8Tk7AM9iLRF0lMTG6fRgakgemmYy547o9nDlt5SUU=s180
81-
[images] => Array
82-
(
83-
[0] => https://lh3.googleusercontent.com/E-v927YsFTavPwOPoQlX3ghrgtwBDs2og-BlkR-uJVjln3zPZn42BQf66DUk3RgLjHQ=w720-h310
84-
[1] => https://lh3.googleusercontent.com/DdUSr7Q3Hn1d6bu9WHRWT3pxRu-kQ08toOUrteVM0PEqq21DL0_bocr2Dkp-V36Ogts=w720-h310
85-
[2] => https://lh3.googleusercontent.com/Zme-HjUlmoiTXsDfuirj6uAnXw4ynuTCKg_VIVFjLZvd6M7RtQ2iwTpddKEBRzaDkw=w720-h310
86-
[3] => https://lh3.googleusercontent.com/ksZiKVJ5xLO1vyY7J8wGiO1jmte8BeGnTvkm1ztZfktVHM4U91nJ5OXiqI5Ns1dajLex=w720-h310
87-
[4] => https://lh3.googleusercontent.com/EOjIutnWGalSQqJXkCzhZ6o4DnhiJZZm58Ai32K99nYooe4aWWpe1HB5PM9MVjM5gsk=w720-h310
88-
[5] => https://lh3.googleusercontent.com/j-YgtRA1U6Pm88cJqjz4rn_WCPAprveqf-ti4lqqnCrtMjmpkldRgh8T-UDSYBCUBko=w720-h310
89-
[6] => https://lh3.googleusercontent.com/Sl8V1J_DYPfkq9QOdFKGlon4debOEHfvLK2FpGmaPi0nenQUF3XbJ88H49shlsINKF4=w720-h310
90-
[7] => https://lh3.googleusercontent.com/2G2MRdimo5m17xMB5V9lQ_3j2BH_jA-y5T8vEx3oktosVXlbUp6FiQ32B3DKG_-_x94=w720-h310
91-
[8] => https://lh3.googleusercontent.com/eiauYcpKC8RwmjfPKhDzlXqmRA_N-wikj1VMf2a3ce_dmGSdUhNOpPN2pJ7fukZE6YV8=w720-h310
92-
[9] => https://lh3.googleusercontent.com/VslU20e8ZUVWM5ac5t9etc7d0I7GFqVQpoMu6zfxcruSAkYLXwDIYpvP2u3vGBoCoP0=w720-h310
93-
[10] => https://lh3.googleusercontent.com/K14ntx3VnpjfvEUlxkW9Q7DxCalbw3_bAP-t3b0jS4gzsI_WqKo6m6w2eR2vCvG3ygo=w720-h310
94-
[11] => https://lh3.googleusercontent.com/pqbjnQHoHsYDYicHJgw0GzO-6B4wyc8Xn39zl9LyarNBQad4FBpz6GYJCfLFrEurkUo=w720-h310
95-
)
96-
97-
[updated] => May 24, 2020
98-
[version] => 1.10.1
99-
[require] => 4.4 and up
100-
[install] => 500,000+
101-
[age] => Everyone
102-
[rating] => 3.9
103-
[votes] => 1,820
104-
[price] => 0
105-
[size] => Varies with device
106-
[ads] => 0
107-
[iap] => 0
108-
[success] => 1
109-
)
110-
```
111-
112-
On failure, the result looks like this:
113-
114-
```
115-
Array
116-
(
117-
[success] => 0
118-
[message] => HTTP/1.0 404 Not Found
119-
)
120-
```
121-
122-
The message most often is the "server response" – but could also be something like `'No app data found'` if server response indicated success but the results were not parsable.
123-
124-
125-
### Obtaining app permissions
126-
Using `$google->parsePerms($packageName)` you can obtain permissions for a given app. As with the structures returned for apps, the keys `success` and `message` are used to indicate the status. For data itself, you'll find a list by permission groups behind the `grouped` key – and "unified permissions" behind the `perms` key. Example output:
127-
128-
```
129-
Array
130-
(
131-
[success] => 1
132-
[grouped] => Array
133-
(
134-
[storage] => Array
135-
(
136-
[group_name] => Storage
137-
[perms] => Array
138-
(
139-
[0] => Array
140-
(
141-
[0] =>
142-
[1] => modify or delete the contents of your USB storage
143-
)
144-
[1] => Array
145-
(
146-
[0] =>
147-
[1] => read the contents of your USB storage
148-
)
149-
)
150-
)
151-
[perm_media] => Array
152-
(
153-
[group_name] => Photos/Media/Files
154-
[perms] => Array
155-
(
156-
[0] => Array
157-
(
158-
[0] =>
159-
[1] => modify or delete the contents of your USB storage
160-
)
161-
[1] => Array
162-
(
163-
[0] =>
164-
[1] => read the contents of your USB storage
165-
)
166-
)
167-
)
168-
[perm_camera_mic] => Array
169-
(
170-
[group_name] => Microphone
171-
[perms] => Array
172-
(
173-
[0] => Array
174-
(
175-
[0] =>
176-
[1] => record audio
177-
)
178-
)
179-
)
180-
)
181-
[perms] => Array
182-
(
183-
[0] => modify or delete the contents of your USB storage
184-
[1] => read the contents of your USB storage
185-
[4] => record audio
186-
)
187-
)
188-
```
189-
190-
The `grouped` keys are the IDs given to the permission groups by Google. The empty `[0]` key for permissions in the `grouped` tree is as shipped by Google; no idea what it is reserved for until some values show up here.
191-
192-
For results on failure, please see above.
37+
## Detailed instructions
38+
Examples of how to use the code and what results to expect can be found in the [wiki](https://github.com/BaseMax/GooglePlayWebServiceAPI/wiki):
19339

194-
### Obtaining language-specific content
195-
You want descriptions in your own language? The `parseApplication()` method accepts two optional parameters: your language, and your location (eg for currency). Both should be according to [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), e.g. `en` for English, `de` for German, `fr` for French. The method `parsePerms()` also expects a single language parameter, again using ISO 639-1 specifications.
40+
- the [Search](https://github.com/BaseMax/GooglePlayWebServiceAPI/wiki/Search) page shows how to
41+
- list available categories as well as obtain a list of apps from a given category
42+
- search for "similar apps"
43+
- search for apps by keywords
44+
- action as a crawler and find more applications?
45+
- the [AppDetails](https://github.com/BaseMax/GooglePlayWebServiceAPI/wiki/AppDetails) page shows how to
46+
- obtain details about a given app
47+
- interprete the result set (aka the "application structure")
48+
- obtain content in specific languages
49+
- the [Permissions](https://github.com/BaseMax/GooglePlayWebServiceAPI/wiki/Permissions) page details
50+
- how to get the permissions an app requests
51+
- what the result set looks like and how to interprete it
19652

197-
Note that due to technical limitation, not everything is translated.
19853

19954

200-
### TODO
55+
## TODO
20156

20257
- Unit test
20358

google-play.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,18 @@ public function parseApplication($packageName, $lang='en_US', $loc='US') {
147147
/** Parse page specified by URL for playstore links and extract package names
148148
* @method public parse
149149
* @param optional string link link to parse; if empty or not specified, defaults to 'https://play.google.com/apps'
150+
* @param optional bool is_url whether the link passed is an url to fetch-and-parse (true, default) or a string just to parse (false)
150151
* @return array array of package names
151152
*/
152-
public function parse($link=null) {
153-
if($link == "" || $link == null) {
154-
$link = "https://play.google.com/apps";
153+
public function parse($link=null, $is_url=true) {
154+
if ( $is_url ) {
155+
if ($link == "" || $link == null) {
156+
$link = "https://play.google.com/apps";
157+
}
158+
$input = file_get_contents($link);
159+
} else {
160+
$input = $link;
155161
}
156-
$input = file_get_contents($link);
157162
preg_match_all('/href="\/store\/apps\/details\?id=(?<ids>[^\"]+)"/i', $input, $ids);
158163
if ( isset($ids["ids"]) ) {
159164
$ids = $ids["ids"];
@@ -249,6 +254,20 @@ public function parseCategories() {
249254
return array_unique($cats[1]);
250255
}
251256

257+
/** Obtain list of similar apps
258+
* @method parseSimilar
259+
* @param string packageName package name of the app to find similars for, e.g. 'com.example.app'
260+
* @return array array of package names
261+
*/
262+
public function parseSimilar($packageName) {
263+
if ( ! $this->getApplicationPage($packageName) )
264+
return ['success'=>0,'message'=>$this->lastError];
265+
$input = $this->getRegVal('!<h2 class="sv0AUd bs3Xnd">Similar</h2></a>(?<content>.+?)(<c-wiz jsrenderer="rx5H8d"|</aside>)!ims');
266+
if ( empty($input) )
267+
return ['success'=>0,'message'=>'no data found'];
268+
return $this->parse($input, false);
269+
}
270+
252271
/** Search for apps by a given string
253272
* @method public parseSearch
254273
* @param string query string to search for

0 commit comments

Comments
 (0)