dev-master
9999999-dev https://github.com/smartinm/mega-php-clientMEGA API Client Library for PHP.
MIT
The Requires
- ext-mcrypt *
- ext-openssl *
- ext-curl *
- php >=5.3.0
api client mega mega.co.nz
MEGA API Client Library for PHP.
PHP client library for the MEGA API., (*1)
Note: This library is still under development and incomplete, so the API is subject to change., (*2)
$mega = new MEGA();
$mega = MEGA::create_from_login($email, $password);
This is equivalent to:, (*3)
$mega = new MEGA(); $mega->user_login_session($email, $password);
MEGA::set_default_server(MEGA::SERVER_EUROPE);
Download public files not require authentication., (*4)
$mega = new MEGA(); $file_info = $mega->public_file_info($ph, $key); var_dump($file_info); // Print filename and size echo 'Filename: ' . $file_info['at']['n']; echo 'Size: ' . $file_info['s'];
$file_info = $mega->public_file_info_from_link($link);
This is equivalents to:, (*5)
$info = MEGA::parse_link($link); $file_info = $mega->public_file_info($info['ph'], $info['key']);
// Save file to current directory. $filepath = $mega->public_file_save($ph, $key); echo 'File saved in ' . $filepath; // Equivalent using exported link $filepath = $mega->public_file_save_from_link($link); echo 'File saved in ' . $filepath;
See below for more examples., (*6)
// Write to file $fp = fopen($file, 'wb'); $size = $mega->public_file_download($ph, $key, $fp); fclose($fp);
// Get content using temporary stream $content = $mega->public_file_download($ph, $key);
// Save file to temporary directory. $tmp = sys_get_temp_dir(); $file = $mega->public_file_save($ph, $key, $tmp); echo 'File saved in ' . $file;
$mega = MEGA::create_from_user($email, $password); $files = $mega->node_list(); print_r($files); // Get file info $file_info = $mega->node_file_info($files['f'][5]); print_r($file_info);
node_file_save()
function is equivalent to public_file_save()
node_file_download()
function is equivalent to public_file_download()
$mega = MEGA::create_from_user($email, $password); // ... // Get current session as a base64 string $session = MEGA::session_save($mega); // Store in a safe place! db_store_session($session);
// Retrive saved session $session = db_get_session(); // Create client from previous session $mega = MEGA::create_from_session($session); // ...
Method | Description | Status |
---|---|---|
public_file_info |
Request public file info | Implemented |
public_file_info_from_link |
Request public file info | Implemented |
public_file_download |
Download a public file | Implemented |
public_file_download_from_link |
Download a public file | Implemented |
public_file_save |
Download and save a public file to disk | Implemented |
public_file_save_from_link |
Download and save a public file to disk | Implemented |
Method | Description | Status |
---|---|---|
node_list |
Retrieve folder or user nodes | Implemented |
node_file_info |
Request file node info | Implemented |
node_file_download |
Download a file node | Implemented |
node_file_save |
Download and save a file node to disk | Implemented |
node_add |
Add/copy nodes | Not implemented |
node_delete |
Delete node | Not implemented |
node_move |
Move node | Not implemented |
node_update |
Set node attributes | Not implemented |
node_publish / node_unpublish
|
Create/delete public handle | Not implemented |
node_share |
Create/modify/delete outgoing share | Not implemented |
This library has been written by Sergio MartĂn (@smartinm) as a port of official MEGA Javascript code., (*7)
Part of the code is based on the work done by Julien Marchand., (*8)
This projected is licensed under the terms of the MIT license., (*9)
MEGA API Client Library for PHP.
MIT
api client mega mega.co.nz