用PHP模擬401給C#判斷
資料來源:
GOOGLE: php set 401 header
https://stackoverflow.com/questions/15914130/throwing-a-401-header-with-php-without-redirect
GOOGLE: httpwebrequest WebException
https://msdn.microsoft.com/zh-tw/library/system.net.webexception.response(v=vs.110).aspx
<?PHP
//—
//用PHP模擬401給C#判斷
//GOOGLE: php set 401 header
//https://stackoverflow.com/questions/15914130/throwing-a-401-header-with-php-without-redirect
//GOOGLE: httpwebrequest WebException
//https://msdn.microsoft.com/zh-tw/library/system.net.webexception.response(v=vs.110).aspx
/*
C# code
String data=”{\”data\”:\”中文\”,\”value\”:100}”;
CS2PHPrestfulapi.RESTfulAPI_postBody(“http://127.0.0.1:8080/set_401.php”, data);
*/
header(“HTTP/1.1 401 Unauthorized”);
exit;
//—用PHP模擬401給C#判斷
?>
|