siegsb / play-extractor
轻松地从Play Store提取信息,就像使用API一样
Requires
- php: >=5.4
Requires (Dev)
- phpdocumentor/phpdocumentor: 2.*
- phpunit/phpunit: >=4.8
- squizlabs/php_codesniffer: ^2.3
This package is not auto-updated.
Last update: 2024-09-18 08:01:49 UTC
README
本项目是PlayStoreApi项目的一个分支,但与此项目没有任何关联。感谢RedInput,这是本项目所基于的原库的开发者。
Play Extractor提供了一个Composer PHP库,用于从Play Store提取各种项目的信息,如专辑、应用、艺术家等。
不需要任何类型的认证,支持Play Store网站上所有可用的语言和国家。
安装
在PHP项目中安装PlayExtractor的最佳方法是使用Composer,只需将以下行添加到您的require中
"siegsb/play-extractor": "1.0.*"
然后使用composer update更新您的Composer项目。您也可以将此存储库克隆到项目路径中,但推荐的方法是通过Composer。
使用
首先将autoload.php文件包含到您的PHP脚本中,并设置要使用的命名空间
require_once __DIR__ . '/vendor/autoload.php'; use \SiegSB\PlayExtractor;
然后您可以使用ISO-2格式使用locale和country参数创建一个新的PlayExtractor对象
$playExtractor = new PlayExtractor('en', 'US');
现在您可以请求Play Store上任何类型内容的详细信息
/** * @param $contentId string. The unique ID for the content, see the Supported Contents to more information * @return $details DataObject. The details of the content as a object of the requested content, see the Supported Contents to more information */ $playExtractor->details->album($contentId); $playExtractor->details->app($contentId); $playExtractor->details->artist($contentId); $playExtractor->details->book($contentId);
支持的内容
目前PlayExtractor支持以下内容,每个条目中都有更多信息
专辑
此对象具有以下方法
// Returns the album ID, the same that you use when you call $playExtractor->details->album() $album->getAlbumId(); // Returns the URL of the album cover $album->getImage(); // Returns the title of the album $album->getTitle(); // Returns the artist name $album->getArtist(); // Returns the artist ID, you can use it to request the artist details $album->getArtistId(); // Returns the price based on your PlayExtractor language and country configuration $album->getPrice(); // Returns the Play Store URL of the album $album->getUrl(); // Returns the description of the album $album->getDescription(); // Returns the genre $album->getGenre(); // Returns the number of tracks $album->getTracks(); // Returns the total rating of the album as a float $album->getRatingValue(); // Returns the number of ratings $album->getRatingCount();
应用
此对象具有以下方法
// Returns the package name, this is the contentId $app->getPackage(); // Returns the URL of the icon like PNG $app->getIcon(); // Returns the public name of the app $app->getName(); // Returns the public name of the developer $app->getDeveloper(); // Returns the price of the app based in your PlayExtractor configuration $app->getPrice(); // Returns the Play Store URL of the app $app->getUrl(); // Returns the app description $app->getDescription(); // Returns the category $app->getCategory(); // Returns the total rating of the app as a float $app->getRatingValue(); // Returns the number of ratings $app->getRatingCount(); // Returns the size of the APK file $app->getFileSize(); // Returns the date of the last update as a string date format $app->getDateUpdated(); // Returns the number of downloads $app->getNumDownloads(); // Returns the current app version $app->getVersion(); // Returns the minimum Android version that the app requires $app->getRequiredAndroid(); // Returns the content rating $app->getContentRating(); // Returns the features of the app, e.g. if have ads or in-app purchases. // returns an array. $app->getFeatures(); // Returns the values for the in-app purchases if apply. $app->getInAppPrices();
艺术家
此对象具有以下方法
// Returns the artist ID $artist->getArtistId(); // Returns the URL of the artist image as PNG $artist->getImage(); // Returns the public artist name $artist->getName(); // Returns the Play Store URL of the artist $artist->getUrl(); // Returns the biography of the artist $artist->getAbout();
书籍
此对象具有以下方法
// Returns the book ID $book->getBookId(); // Returns the URL of the book cover as PNG $book->getImage(); // Returns the title $book->getTitle(); // Returns the public author name $book->getAuthor(); // Returns the price $book->getPrice(); // Returns the Play Store URL of the book $book->getUrl(); // Returns the description of the book $book->getDescription(); // Returns the total number of pages $book->getPages(); // Returns the language of the book $book->getLanguages(); // Returns the ISBN code $book->getIsbn(); // Returns the total rating as a float $book->getRatingValue(); // Returns the number of ratings $book->getRatingCount();
异常
如果语言或国家代码对Play Store无效,或者请求的内容不存在,PlayExtractor将返回异常。
提示
您可以使用json_encode()方法与任何数据对象一起使用,以轻松转换为JSON,例如
print json_encode($artist);
这将返回以下JSON字符串
{
"artist_id": "",
"image": "",
"name": "",
"url": "",
"about": ""
}
合作与拉取请求
为了保持代码清晰,库中所有脚本都必须按照PSR-2格式进行格式化,并使用PSR-4和命名空间进行自动加载。尽可能保持库与PHP 5.4的最小兼容性。如果不需要,请不要修改composer.json,并且需要使用Travis进行构建测试。
如果您想添加新功能,请在代码中使用注释添加正确的注释,并在tests路径中创建PHPUnit测试用例。您还应该在提交消息中保持清晰。注意其他开发者的信息,并确保不要从composer文件中删除它们,同时验证您的信息(如果需要)是否正确。
谢谢!