php-extended/php-api-nz-mega-object
Composer 安装命令:
composer require php-extended/php-api-nz-mega-object
包简介
A library that implements the php-extended/php-api-nz-mega-interface library
README 文档
README
A php API wrapper to connect to mega.nz API, in full object oriented mode.
This library takes care of not disabling https certificate checking when calling for mega servers.
This API is in construction, only few of its methods are available, but contributions are welcome !
/!\ Mega seems to badly support the file_get_contents() function.
/!\ Use a curl-based http client for better performance.
This library is inspired by the smartinm/mega-php-client library and the tutorial by Julien Marchand.
Installation
The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.
- Download
composer.pharfrom their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-api-nz-mega-object ^9
Basic Usage
For downloading the files of a folder on mega, and put them into a folder on your filesystem, please look at the example script.
This library offers an API to see files, and download them, as follows :
The constructor needs the path and key to access mega.
MegaEndpoint : : __construct(HttpJsonEndpoint $endpoint, string $full_url) : Mega
Once a new MegaEndpoint object is created, you may search for its root folder with
the method : MegaEndpoint : : getRootNodeInfo() : MegaNode;
Once you have a MegaNode object, you may search for its children with the
method :
MegaEndpoint : : getChildren(MegaNodeId $node_id) : MegaNode[];
The MegaNodeId object may be obtained with the MegaNode : getNodeId() : MegaNodeId
method. Node Ids are common objects to refer to specific nodes in a hierarchy,
and the Mega class may retrieve MegaNode objects with the method
MegaEndpoint : : getNodeInfo(MegaNodeId $node_id) : MegaNode.
To separate nodes that represents folders and node that represents files, use
the MegaNode : : getNodeType() : integer method. If the value is MegaNode : : TYPE_FOLDER,
then the node represents a folder, and if the value is MegaNode : : TYPE_FILE,
then it represents a downloadable file.
Then, to download files (folders are not downloadable for obvious reasons),
use the MegaEndpoint : : downloadFile(MegaNode $node) : string method, that
returns the raw string data of the downloaded file, unencrypted.
Beware that this method does not uses streams directly to your filesystem, and may use a lot of memory if the file is really big.
To check the size of a file (folders have no size given Mega's API), use the
MegaNode : : getNodeSize() : integer method. Beware that 32 bits system
(or 32 bits php as windows have) may not handle the file sizes for large files
very well.
Finally, almost every method of this library throws PhpExtended\Mega\MegaException
dues to various factors, mainly because cryptographic errors that may occur anywhere.
Remember to encapsulate calls to this library with try
{ ... } catch(MegaException $e) { ... }
blocks.
License
MIT (See license file).
php-extended/php-api-nz-mega-object 适用场景与选型建议
php-extended/php-api-nz-mega-object 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.12k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「api」 「object」 「implementation」 「mega.nz」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 php-extended/php-api-nz-mega-object 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 php-extended/php-api-nz-mega-object 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 php-extended/php-api-nz-mega-object 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A set of useful PHP classes.
Runn Me! Value Objects Library
Laravel SDK mapping data in object
A PSR-7 compatible library for making CRUD API endpoints
CitaNZ's SilverStripe picture object and field for SilverStripe 4
Uses reflection to map XML to PHP objects.
统计信息
- 总下载量: 6.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-12