Home >Backend Development >PHP Tutorial >PHP implements Xiaomi 3 availability detection and then sends email

PHP implements Xiaomi 3 availability detection and then sends email

WBOY
WBOYOriginal
2016-07-25 08:47:461056browse
I wanted to buy the Xiaomi Mi 3 telecom version today, but it was sold out every time it was shipped, so I did a simple check to see if it was in stock.

Then I successfully grabbed the white telecom version of Xiaomi Mi 3 today.

The arrays inside are for different versions. I only want the telecom version, so I wrote down three simple judgments

  1. $curl = curl_init();
  2. curl_setopt($curl, CURLOPT_URL, "http://www.mi.com/buyphone/mi3");
  3. curl_setopt($curl, CURLOPT_HEADER, 0 );
  4. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  5. $data = curl_exec($curl);
  6. curl_close($curl);
  7. preg_match_all("/isLack:(.*),/",$data,$out );
  8. if($out[1][24]=='false'){
  9. mail("admin@qq.com","Xiaomi 3 black telecom version is in stock","Purchase address http://order .mi.com/event/selectPacket/goodsid/2140800022");
  10. }else{
  11. echo "Wait";
  12. }
  13. if($out[1][23]=='false'){
  14. mail(" admin@qq.com","Xiaomi 3 white telecom version is in stock","Purchase address http://order.mi.com/event/selectPacket/goodsid/2141000021");
  15. }else{
  16. echo "Wait" ;
  17. }
  18. if($out[1][25]=='false'){
  19. echo "Buy";
  20. mail("admin@qq.com","Xiaomi 3 Silver Telecom Edition is in stock", "Purchase address http://order.mi.com/event/selectPacket/goodsid/2141300016");
  21. }else{
  22. echo "Wait";
  23. }
Copy code


Statement:
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