| Server IP : 104.21.80.248 / Your IP : 172.71.28.155 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Inetpub/www/news/csr/admin/core/ |
Upload File : |
<?
$url = 'http://api.bopp-obec.info/Students/api/Authen';
$data = array(
"PersonId"=>'3770200413935',
"Password"=>'38j7GX2ah$f4dpk'
);
$url_sch = "http://api.bopp-obec.info/Students/api/Schools"; // error 404
$url_stud = "http://api.bopp-obec.info/Students/api/Students/G612000007061";
$token = get_Authenticate($url, $data);
$sch = gat_school_info($url_sch,$token);
echo $sch;
function get_Authenticate($url, $data){
$payload = json_encode( $data );
$ch = curl_init( $url );
//attach encoded JSON string to the POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
//set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
//return response instead of outputting
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//execute the POST request
$result = curl_exec($ch);
curl_close($ch);
return $result ;
}
function gat_school_info($url, $token){
$ch = curl_init( $url );
$a = json_decode( $token,true);
//echo "<br> aaa ==="; print_r($a);
$token_txt = $a["token" ];
// Returns the data/output as a string instead of raw data
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Set your auth headers
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $token_txt
));
// get stringified data/output. See CURLOPT_RETURNTRANSFER
$data = curl_exec($ch);
//echo "<br>1===============<br>"; echo $data ;
// get info about the request
$info = curl_getinfo($ch);
// echo "<br>2===============<br>"; print_r($info);
// close curl resource to free up system resources
curl_close($ch);
return $data ;
}