-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,309 additions
and
306 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
namespace libs; | ||
/**http请求模块 | ||
* Created by PhpStorm. | ||
* User: SD | ||
* Date: 2016/7/7 | ||
* Time: 15:27 | ||
*/ | ||
class HttpRequest | ||
{ | ||
//利用file_get_contents获取数据 | ||
public static function request($url, $params=[], $method='GET'){ | ||
$res = null; | ||
if(preg_match("/^(http|https)\:\/\/(\w+\.\w+\.\w+)/", $url)){ | ||
$method = strtoupper($method); | ||
if($method=='GET'){ | ||
if ($params) { | ||
if (strripos('?', $url)) { | ||
$url = $url . '&' . http_build_query($params); | ||
} else { | ||
$url = $url . '?' . http_build_query($params); | ||
} | ||
} | ||
$res = file_get_contents($url); | ||
} elseif($method=='post') { | ||
exit("$method have none"); | ||
}else{ | ||
exit("$method have none"); | ||
} | ||
} | ||
return $res; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
namespace app; | ||
/** | ||
* Created by PhpStorm. | ||
* User: SD | ||
* Date: 2016/7/6 | ||
* Time: 15:37 | ||
*/ | ||
use libs\HttpRequest; | ||
|
||
class QueryPhone | ||
{ | ||
/** | ||
* 淘宝api | ||
* https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=130******** | ||
*/ | ||
const PHONE_API = 'https://tcc.taobao.com/cc/json/mobile_tel_segment.htm'; | ||
const BAIDU_API_PHONE = 'http://apis.baidu.com/apistore/mobilenumber/mobilenumber?phone'; | ||
const BAIDU_PAI_apikey = '14153e647b7aa96a4be61d8f90468e6c'; | ||
|
||
const QUERY_PHONE = 'PHONE:INFO:'; | ||
|
||
private static function _formatData($data) | ||
{ | ||
$ret = null; | ||
if (!empty($data)) { | ||
preg_match_all("/(\w+):'([^']+)/", $data, $res); | ||
$items = array_combine($res[1], $res[2]); | ||
foreach ($items as $itemKey => $itemVal) { | ||
$ret[$itemKey] = iconv('GB2312', 'UTF-8', $itemVal); | ||
} | ||
} | ||
return $ret; | ||
} | ||
|
||
public static function verifyPhone($phone) | ||
{ | ||
if (preg_match("/^1[34578]{1}\d{9}/", $phone)) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
public static function query($phone) | ||
{ | ||
$phoneData = null; | ||
if (self::verifyPhone($phone)) { | ||
//TODO 加缓存 | ||
$response = HttpRequest::request(self::PHONE_API, ['tel' => $phone]); | ||
|
||
$phoneData = self::_formatData($response); | ||
|
||
$phoneData['msg'] = '数据由阿里巴巴提供'; | ||
|
||
} | ||
return $phoneData; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* 测试 | ||
* Created by PhpStorm. | ||
* User: SD | ||
* Date: 2016/7/6 | ||
* Time: 15:36 | ||
*/ | ||
include_once "autoload.php"; | ||
use app\QueryPhone; | ||
|
||
|
||
|
||
$tel = $_POST['phone'] ?? 15251895564; | ||
|
||
$response = QueryPhone::query($tel); | ||
|
||
if(is_array($response)&&isset($response['province'])){ | ||
$response['phone'] = $tel; | ||
$response['code'] = 200; | ||
}else{ | ||
$response['code'] = 400; | ||
$response['msg'] = "手机号码错误"; | ||
} | ||
|
||
echo json_encode($response); | ||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>从www.henha.com获取图片资源</title> | ||
<link type="text/css" href="static/css/bootstrap.min.css" rel="stylesheet"> | ||
<script type="application/javascript" src="static/js/jquery-3.0.0.min.js"></script> | ||
<script type="application/javascript" src="static/js/jquery.cookie.js"></script> | ||
<script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> | ||
</head> | ||
<body> | ||
<header style="height: 100px;"></header> | ||
<div class="container"> | ||
<div class="row"> | ||
<form class="form-horizontal" action="#" method="post"> | ||
<div class="form-group"> | ||
<label for="start-number" class="col-sm-2 control-label">起始页</label> | ||
<div class="col-sm-10"> | ||
<input type="number" class="form-control" id="start-number" name="start-number" placeholder="从零开始" required min="0" step="1" value=""> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="all-number" class="col-sm-2 control-label">下载数量</label> | ||
<div class="col-sm-10"> | ||
<input type="number" class="form-control" id="all-number" name="all-number" placeholder="上限500" aria-valuemax="500" required max="500" step="1"> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-sm-12 text-right"> | ||
<button type="submit" class="btn btn-primary btn-lg">确定</button> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
</body> | ||
<script> | ||
function init(){ | ||
var start_num = parseInt($.cookie('end_num'))+1; | ||
$('#start-number').val(start_num); | ||
} | ||
window.onload=init(); | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.