Skip to content

Instantly share code, notes, and snippets.

@smaznet
Last active August 29, 2017 08:12
Show Gist options
  • Save smaznet/5b5604d433caa6bf92cb7957e56c8bb6 to your computer and use it in GitHub Desktop.
Save smaznet/5b5604d433caa6bf92cb7957e56c8bb6 to your computer and use it in GitHub Desktop.
گرفتن تعداد ادمین های کانال تلگرام
<?php
function getAdminsCount($username,$token){
$html_site = file_get_contents('https://t.me/'.substr($username,1));
$htm = new DOMDocument();
$htm->loadHTML($html_site);
$finder = new DomXPath($htm);
$classname = 'tgme_page_extra';
$nodes = $finder->query("//*[contains(@class, '$classname')]");
$members = $nodes->item(0)->textContent;
$count = preg_replace("/[^\d]/",'',$members);
$all= file_get_contents('https://api.telegram.org/bot'.$token .'/getChatMembersCount?chat_id='.$username);
$all= json_decode($all)->result;
return $all-$count;
}
// استفاده :
// just public channels and groups Username
echo getAdminsCount("@pgming",BOT_TOKEN);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment