Mokhoa oa ho fihlella sebopeho sa API se fanoeng ke EMQX
Tšupiso
Webosaete ea semmuso HTTP API Protocol ea HTTPTheha kopo ebe o hlakisa khoutu ea tumello
Kena ho setsi sa taolo ea sengoloa sa EMQX. Haeba ho se liphetoho tse entsoeng, aterese ea setsi sa taolo e lokela ho ba port 18083 ea seva IP. Kamora ho kena ka katleho ho setsi sa taolo ea WEB, tlanya "General" le "Application" ka tatellano. Pele re theha APP e ncha, ID le lebitso la APP li ka kenngoa ka thato, khetho ea maemo e lumella phihlello, mme letsatsi la ho felloa ke nako le khethoa ho latela litlhoko tsa 'nete. Kamora hore popo e atlehe, hlakola kopo ea kamehla ea EMQX, ho seng joalo ho tla ba le likotsi tsa ts'ireletso. Re boetse re hloka ho fana ka maikutlo mabapi le ak'haonte ea APP ea mantlha le phetolo ea senotlolo ho /etc/emqx/plugins/emqx_management.conf, ho seng joalo APP ea mantlha e tla nchafatsoa kamora ho qala bocha tšebeletso ea EMQX. Ebe re khutlela ho leqephe la lenane la likopo ebe re tobetsa View in the operation ho bona ts'ebeliso eo re sa tsoa e etsa.
Sebopeho sa API sa tlhahlobo
Kamora hore re fumane senotlolo sa APP, re ka sebelisa likopo tsa HTTP ho fihlella sebopeho sa API. Ho bohlokoa ho hlokomela hore re hloka ho kenya tlhahisoleseling ea tumello ho Hlooho Bakeng sa lintlha, ka kopo sheba mohlala o latelang. Bakeng sa litlhaloso tsa li-interface tse ling, ka kopo sheba sets'oants'o sa semmuso se kaholimo ho sengolo. Lirapeng tse peli tse latelang tsa mehlala, serapa sa pele ke kopo e tobileng ea CURL moleng oa taelo ea Linux, mme serapa sa bobeli ke kopo e sebelisang khoutu ea PHP.
curl -i --basic -u app_id:app_key-X GET "http://localhost:8081/api/v4/nodes"
$app_id = 'app_id';
$app_key = 'app_key';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Basic '.base64_encode($app_id.':'.$app_key)]);
$result = curl_exec($ch);
curl_close($ch);
echo $result;