Skip to main content

The PHP language

2020/6/14.  The PHP language


Recently, I am learning PHP language.
PHP language is server-side language, and it is useful for web watching.

I wrote below code for web-watching to take the Mensa Japan exam.
(I am already Mensa member.)(And I don’t know this code will work well.)
Below code notifies with LINE app, so if you want to use it, you have to get permission from LINE development.
And you need to set some settings on your smartphone.

This is only test code, and if you want to use this code, you need some knowledge about Information technology.
And if you can use Linux crontab, this code runs every time.

I know you don’t need to take Mensa Japan exam.
This is just sample for getting a ticket which is difficult to get online.

First, I tried to use e-mail, but the e-mail’s security setting is too difficult.
So, I changed to use LINE app.
I took few weeks for writing below code, programming is so hard… Of course it is fun.

I started learning programming 2.5 years ago…
It was long time, but I got reached very far place from it…

(Code) *** is your LINE token.

<?php

$url = 'https://mensa.jp/exam/'; 
$filename = '/home/pi/Desktop/Mensa-exam-judge.txt'; 

$input = file_get_contents($url);
$prv = file_get_contents($filename);

$match1 = mb_strstr($input, '関東地方</h3>');
$match1 = str_replace(array(" ", " "), "", $match1);
$match1_1 = mb_strstr($match1, '</p>', true);
//var_dump($match1_1);

$match2 = mb_strstr($prv, '関東地方</h3> ');
$match2 = str_replace(array(" ", " "), "", $match2);
$match2_1 = mb_strstr($match2, '</p>', true);
//var_dump($match2_1);

if($match1_1 != $match2_1){

echo "NO";

define('LINE_API_URL'  ,'https://notify-api.line.me/api/notify');
define('LINE_API_TOKEN’,’***’);

function post_message($message){

    $data = http_build_query( [ 'message' => $message ], '', '&');

    $options = [
        'http'=> [
            'method'=>'POST',
            'header'=>'Authorization: Bearer ' . LINE_API_TOKEN . "\r\n"
                    . "Content-Type: application/x-www-form-urlencoded\r\n"
                    . 'Content-Length: ' . strlen($data)  . "\r\n" ,
            'content' => $data,
            ]
        ];

    $context = stream_context_create($options);
    $resultJson = file_get_contents(LINE_API_URL, false, $context);
    $resultArray = json_decode($resultJson, true);
    if($resultArray['status'] != 200)  {
        return false;
    }
    return true;
}
post_message("Mensa Exam!+ ${url}");

$fp = fopen($filename, 'w');
fwrite($fp, $input);
fclose($fp);


}else {
    
echo "YES";

}
?>

Popular Posts

Communication difficulties

2017/5/28. Improving emotional reaction : Communication  Emotional answer often makes mistakes. Finding own unconscious emotions is simple solution to improve communication. How to find it ? Like or not like , comfort or not comfort... No. I read this answer by book. There are 5 patterns about relationships with others. Positive & Active people  Positive & Passive people  Negative & Active people  Negative & Passive people  Center & Neutral people  If other people's reaction is positive & active on communication , I am in negative & passive position. And if some people gets angry on brain imaging , they are negative & active people for me. And they see me as positive & passive people. Emotional stress is happened from the misunderstanding how others see me. Misunderstanding is happened between how I see myself and how others see me. So improving emotional reaction is to know how ot...

The Solicitation

  2020/12/27.     The Solicitation   When I was in Cafe, I saw the solicitation for automatic investment system (must be scam) between 2 young men. I watched them and found some things. (1)They were telling about FX or stock automatic investment tools. ->A lot of people are trying it with very efforts. (2)The solicitor was using tablet device, but recruited person was using paper and pencil. ->There is very big digital information difference between them. (3)The solicitor told that this tools would bring money forever. ->100% scam. —>The result from (1)(2)(3), I thought that the scam is happened when there is information difference. Thinking about solicitation, we have to rethink if we are hunter or food.

Own view to World and I

  Own view to World and I I thought about feeling method about world and I. The principle questions are “What is the World?”, “Who am I?”. There are several feelings about these questions’ answers. View to World and I I am [ positive ] I am [ normal ] I am [ negative ] World is [ positive ] Normal A Mismatch B1 Mismatch C World is [ normal ] Positive thinking Normal B Negative thinking World is [ negative ] Mismatch A Mismatch B2 Normal C I categorized the answers in above matrix. If “World is [negative]” and “I am [normal]” is the answer, Mismatch B2 is my position. Then if we want to change something, we should change view to the world or I.

Cheaper work

2016/12/29. Cheaper works: Hard competition makes expensive work cheaper. In Japan, there are some people who thinks there are a lot of workers, and they are exchangeable easily. This thought can't stand on human populations decreasing society. And in this society, the flow that provides products cheaper and cheaper cannot keep. Now, Japanese society is standing on that thought, and Japanese system hardly stands. This is by the patience of Japanese. When the breaking point of Japanese system comes, the counter of patience will keeps long time. And I think that communism never comes in Japan. Because Karl Marx doesn't think about human populations decreasing...