Uname: Linux premium264.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.3.22 [ PHP INFO ] PHP os: Linux
Server Ip: 69.57.162.13
Your Ip: 216.73.216.219
User: workvvfb (1129) | Group: workvvfb (1084)
Safe Mode: OFF
Disable Function:
NONE

name : GooglePlayInfo.php
<?php

namespace AppBuilder\Classs;

defined( 'ABSPATH' ) || exit;

/**
 * GooglePlayInfo Class.
 */
class GooglePlayInfo {

	/**
	 * Get Google Play Info
	 *
	 * @param string $package_name Package name.
	 * @param string $country Country.
	 *
	 * @return array
	 */
	public static function get_google_play_info( $package_name, $country = 'US' ) {
		$url  = 'https://play.google.com/store/apps/details?id=' . $package_name . '&hl=en' . '&gl=' . $country;
		$html = '';

		$res = app_builder()->get( 'http' )->get( $url );

		if ( is_wp_error( $res ) ) {
			return array();
		}

		$html = wp_remote_retrieve_body( $res );

		if ( empty( $html ) ) {
			return array();
		}

		// Get current version.
		$matches = array();
		preg_match( '/\[\[\[\"\d+\.\d+\.\d+/', $html, $matches );

		$verion = substr( current( $matches ), 4 );

		// Get changelogs.
		$matches   = array();
		$changelog = '';
		preg_match( '/<div itemprop="description">(.*?)<\/div>/', $html, $matches );
		if ( isset( $matches[1] ) ) {
			$changelog = $matches[1];
		}

		// Get date.
		$matches      = array();
		$updated_date = '';
		preg_match( '/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{1,2}, \d{4}/', $html, $matches );
		if ( isset( $matches[0] ) ) {
			// Format date same input date html.
			$date         = date_create( $matches[0] );
			$updated_date = date_format( $date, 'M d, Y' );
		}

		return array(
			'version'      => $verion,
			'updated_date' => $updated_date,
			'changelog'    => $changelog,
			'platform'     => 'android',
		);
	}
}
© 2025 GrazzMean