Home > Backend Development > PHP Tutorial > Teach you step by step how to do a keyword matching project (search engine) ---- Day 9, teach you how to do it on the ninth day_PHP Tutorial

Teach you step by step how to do a keyword matching project (search engine) ---- Day 9, teach you how to do it on the ninth day_PHP Tutorial

WBOY
Release: 2016-07-13 10:21:01
Original
902 people have browsed it

Teach you step by step how to do keyword matching projects (search engines) ---- Day 9, teach you how to do it on Day 9

Day 9

Review:

8. Teach you step by step how to do keyword matching project (search engine) ---- Day 8

7. Teach you step by step how to do keyword matching project (search engine) ---- Day 7

6. Teach you step by step how to do keyword matching project (search engine)----Day 6

5. Teach you step by step how to do keyword matching project (search engine) ---- Day 5

4. Teach you step by step how to do keyword matching project (search engine) ---- Day 4

3. Teach you step by step how to do keyword matching project (search engine) ---- Day 3

2. Teach you step-by-step how to do keyword matching projects (search engines)----The next day

1. Teach you step by step how to do keyword matching project (search engine) ---- Day 1

After Xiao Shuai Shuai got Yu Boss’s TopClient, he actually discovered that TopClient is Curl. In fact, I can also do it with ExtendedCurl. Xiao Shuai Shuai’s enthusiasm for technology is not as high as usual, so he easily handed it over to Boss Yu. The code given has been modified.

Little Shuaishuai also had an enlightenment one day, and from then on his path suddenly became clear.

Xiao Shuai Shuai’s modified code:

<?<span>php
</span><span>class</span><span> TopClient {
    </span>......

    <span>protected</span> <span>function</span> curl(<span>$url</span>, <span>$postFields</span> = <span>null</span><span>)
    {
        </span><span>$options</span> = <span>array</span><span>(
            CURLOPT_FAILONERROR</span>=><span>false</span>,<span>
            CURLOPT_RETURNTRANSFER</span>=><span>true</span>,<span>
            CURLOPT_CONNECTTIMEOUT</span>=>15,<span>
            CURLOPT_TIMEOUT</span>=>300,<span>
            CURLOPT_FOLLOWLOCATION</span>=>1<span>
        );
        </span><span>$curl</span> = <span>new</span> ExtendedCurl(<span>$options</span><span>);

        </span><span>$reponse</span> = <span>$curl</span>->post(<span>$url</span>,<span>$postFields</span><span>);
        </span><span>if</span>(<span>$curl</span>-><span>hasError()){
            </span><span>throw</span> <span>new</span> <span>Exception</span>(<span>$curl</span>->getError(), 0<span>);
        }</span><span>else</span><span>{
            </span><span>if</span>(200 !== <span>$curl</span>-><span>getHttpCode()){
                </span><span>throw</span> <span>new</span> <span>Exception</span>(<span>$reponse</span>, <span>$curl</span>-><span>getHttpCode());
            }
        }
        </span><span>return</span> <span>$reponse</span><span>;
    }

    </span>......<span>
}</span>
Copy after login

Xiao Shuaishuai was very happy to write down the usage example of getting the baby. The code is as follows:

<span>$client</span> = <span>new</span><span> TopClient();
</span><span>$client</span>->appkey = 'xx'<span>;
</span><span>$client</span>->secretKey = 'xx'<span>;

</span><span>$req</span> = <span>new</span><span> ItemGetRequest();
</span><span>$req</span>->setFields('props_name,property_alias,detail_url,cid,title'<span>);
</span><span>$req</span>->setNumIid(<span>$num_iid</span><span>);
</span><span>$resp</span> = <span>$client</span>->execute(<span>$req</span><span>);

</span><span>if</span>(<span>isset</span>(<span>$resp</span>-><span>code)){
    </span><span>#</span><span> error handle</span>
}<span>else</span><span>{
    </span><span>#</span><span>success handle</span>
}
Copy after login

How to join Taobao Open Platform, please check the official introduction: http://open.taobao.com

Xiao Shuai Shuai couldn't hide his impulse and wanted to show off his strength to the boss.

As soon as I arrived at the company, I couldn’t wait to hand over the code to Boss Yu and let him give me his opinions.

Boss Yu looked at it and said happily: Xiao Shuaishuai, that’s good, you’ve made great progress, keep it up.

Xiao Shuai Shuai touched his head and said humbly: No matter where I am, I always count on Boss Yu’s guidance... (Xiao Shuai Shuai’s ability to flatter people is quite good)

But the boss completely ignored these modest words and said to Xiao Shuai Shuai: Look at the function logCommunicationError that writes logs. Can it be extracted separately and stored as a public diary? I believe you can do it...

As soon as Xiao Shuai Shuai heard this, he knew that there was nothing good he could do to find Boss Yu. For the sake of my merits, at least let me rest more. . .

That’s what Xiao Shuai Shuai thought, but actually he still had to take on this task because he didn’t want Boss Yu to disappoint him and wanted to show a good side in front of Boss Yu.

Xiao Shuaishuai replied: Boss Yu, don’t worry, I’ll take care of it.

Just like that, Xiao Shuai Shuai went back to practice his mental skills and study the writing method of Log storage.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/863582.htmlTechArticleTeach you step by step how to do keyword matching projects (search engines)----On the ninth day, teach you how to do the third Review of the ninth day of nine days: 8. Teach you step by step how to do keyword matching projects (search engines) ---- The eighth...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template