meganz / sdk

MEGA C++ SDK
BSD 2-Clause "Simplified" License
1.33k stars 510 forks source link

Needing help using Mega.nz SDK for scripting #2631

Open Naveeey opened 1 year ago

Naveeey commented 1 year ago

Im not really familiar with c++ , so i have been using chatgpt to help me make a script that will get a temporary link of a folder that last 1 hour, so this is what i got:

include "C:\Users\Uros\Downloads\sdk-master\sdk-master\include\megaapi.h"

include

int main(int argc, char argv[]) { // Initialize the MegaApi object mega::MegaApi megaApi = new mega::MegaApi(NULL, "APIKEY");

// Login to your account
megaApi->login("MAIL", "PASS");
megaApi->fetchNodes();

// Get a handle for the folder you want to share
mega::MegaNode *folderNode = megaApi->getNodeByPath("FOLDERPATH");
if(folderNode==NULL)
{
    std::cout<<"Folder not found"<<std::endl;
    return 1;
}

// Get a public link for the folder
megaApi->getPublicLinks(folderNode);
mega::MegaStringMap *links = megaApi->getPublicLinks(folderNode);
std::string exportLink = links->get("0");

// Print the link
std::cout << "Public Link for the folder: " << exportLink << std::endl;

// Clean up
delete megaApi;
return 0;

}

I have been getting this error on line 22 and 23 : invalid conversion from 'mega::MegaNode*' to 'int' [-fpermissive]| If anyone can help me , or just give me anyother way to automate getting temporary links from Mega , would be awesome