@@ -222,7 +222,7 @@ public function parseApplication($packageName, $lang='en_US', $loc='US') {
222222
223223 $ limit = 5 ; $ proto = '' ;
224224 while ( empty ($ proto ) && $ limit > 0 ) { // sometimes protobuf is missing, but present again on subsequent call
225- $ proto = json_decode ($ this ->getRegVal ("/key: 'ds:4'. hash: '7'. data:(?<content>\[\[\[.+?). sideChannel: .*?\);<\/script/ims " )); // ds:8 hash:22 would have reviews
225+ $ proto = json_decode ($ this ->getRegVal ("/key: 'ds:4'. hash: '7'. data:(?<content>\[\[\[.+?). sideChannel: .*?\);<\/script/ims " )); // DataSource:4 = featureGraphic, video, summary
226226 if ( empty ($ proto ) || empty ($ proto [1 ]) ) {
227227 $ this ->getApplicationPage ($ packageName , $ lang , $ loc );
228228 --$ limit ;
@@ -237,6 +237,38 @@ public function parseApplication($packageName, $lang='en_US', $loc='US') {
237237 }
238238 }
239239
240+ // reviews
241+ $ values ["reviews " ] = [];
242+ if ( $ proto = json_decode ($ this ->getRegVal ("/key: 'ds:7'. hash: '\d+'. data:(?<content>\[\[\[.+?). sideChannel: .*?\);<\/script/ims " )) ) { // DataSource:7 = reviews
243+ foreach ($ proto [0 ] as $ rev ) {
244+ $ r ["review_id " ] = $ rev [0 ];
245+ $ r ["reviewed_version " ] = $ rev [10 ];
246+ $ r ["review_date " ] = $ rev [5 ][0 ];
247+ $ r ["review_text " ] = $ rev [4 ];
248+ $ r ["stars " ] = $ rev [2 ];
249+ $ r ["like_count " ] = $ rev [6 ];
250+ $ r ["reviewer " ] = [
251+ "reviewer_id " =>$ rev [9 ][0 ],
252+ "name " =>$ rev [9 ][1 ],
253+ "avatar " =>$ rev [9 ][3 ][0 ][3 ][2 ],
254+ "bg_image " =>$ rev [9 ][4 ][3 ][2 ]
255+ ];
256+ if ( empty ($ rev [7 ]) ) {
257+ $ r ["reply " ] = [];
258+ } else {
259+ $ r ["response " ] = [
260+ "responder_name " =>$ rev [7 ][0 ],
261+ "response_text " =>$ rev [7 ][1 ],
262+ "response_date " =>$ rev [7 ][2 ][0 ]
263+ ];
264+ }
265+ $ values ["reviews " ][] = $ r ;
266+ }
267+ $ values ["review_token " ] = $ proto [1 ][1 ]; // needed if we want to fetch more reviews later
268+ } else {
269+ $ values ["review_token " ] = '' ;
270+ }
271+
240272 if ($ this ->debug ) {
241273 print_r ($ values );
242274 }
0 commit comments