Skip to content
Home ยป Mengambil Nomer Handphone Semua Mahasiswa

Mengambil Nomer Handphone Semua Mahasiswa

  • by
Spread the love

berikut adalah contoh code untuk mengambil semua nomer handphone semua mahasiswa

<?php

include "./bootstrap.php";

class GetPhone{
	private $admin;
	
	
	private function logStatus($t){
		$f = fopen(__DIR__.'/GetPhone.log','a+');
		if($f){
			$now = new \DateTime();
			$now->setTimezone(new \DateTimeZone('Asia/Jakarta'));
			$time = $now->format('Y-m-d H:i:s');   
			$text = $time.': '.$t."\n";
			echo $text;			
			fwrite($f,$text);
			fclose($f);
		}
	}
	
	public function run(){
		
		$this->admin = new \UniversitySDK\Admin;
		//$this->admin->setHost('http://university');
		$ret = $this->admin->login('[email protected]', 'password');
		
		if(!$ret){
			echo 'failed to login';
			return;
		}
		
		$faculties = $this->admin->getAllFaculties();
		$semesterID = 1022;
		$statusCode = 'A';
		$result = [];
		if($faculties!=NULL){
			foreach($faculties as $fac){
				
				$programs = $this->admin->getAllProgramInFaculty($fac->ID);
				
				if($programs!=NULL){
					foreach($programs as $prog){
						echo $prog->name .PHP_EOL;					
						
						$ret = $this->admin->login('[email protected]', 'password');
						
						if(!$ret){
							echo 'failed to login';
							return;
						}
						
						$stdActs = $this->admin->getStudentActivityByProgramAndSemesterAndStatus($prog->ID, $semesterID,$statusCode);
						
						foreach($stdActs->data as $stdAct){
							$std = $this->admin->findStudent($stdAct->StudentID);
							if($std){
								$data = ['NIM'=>$stdAct->NIM, 'phoneNo'=>$std->address->phoneNo, 'contactNo'=>$std->address->phoneNo];
								$result[] = $data;
							}
						}						
					}
				}
			}
		}
		file_put_contents('phone.json', json_encode($result));
		echo 'done';
		
	}
}

$p = new GetPhone();
$p->run();
 
Butuh bantuan?