php怎么做cdn加速


php做cdn加速的案例:

在对应的php文件中添加以下代码:

function sendURL($push_url_data,$url = 'http://push.dnion.com/cdnUrlPush.do')

{

$ch = curl_init(); //初始化curl

curl_setopt($ch, CURLOPT_URL, $url);//设置链接

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//设置是否返回信息

curl_setopt($ch, CURLOPT_HEADER, 0);//设置HTTP头

curl_setopt($ch, CURLOPT_POST, 1);//设置为POST方式

curl_setopt($ch, CURLOPT_POSTFIELDS, $push_url_data);//POST数据

$response = curl_exec($ch);//接收返回信息

if(curl_errno($ch)){//出错则显示错误信息

print curl_error($ch);

}

$httpCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);

curl_close($ch); //关闭curl链接

switch ($httpCode)

{

case 200:

$response_message = "推送成功";

break;

case 999:

$response_message = "用户名和密码验证出错";

break;

case 997:

$response_message = "域名不合法,不在DNION做加速业务";

break;

case 996:

$response_message = "请求参数获取失败,参数为空等";

break;

case 998:

$response_message = "推送的次数过于频繁,请稍等一分钟后在推送";

break;

case 500:

$response_message = "服务端程序异常,无法处理请求,请重试";

break;

default:

$response_message = "其他未知输入,请联系管理员";

break;

}

echo "时间:".date("Y-m-d H:i:s",time())." 状态: ".$response_message;

//echo "time:".date("Y-m-d H:i:s",time()).$response;//显示返回信息

}

$url = "http://网址/index.html";//多网址以半角,割开

$push_data = 'captcha=验证码后台获取&type=1&url='.$url;

sendURL($push_data);

?>


上一篇:个人备案网站内不能出现什么内容

下一篇:如何监听redis消息队列


php CDN cdn加速
Copyright © 2002-2019 测速网 www.inhv.cn 皖ICP备2023010105号
测速城市 测速地区 测速街道 网速测试城市 网速测试地区 网速测试街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!

热门搜索 城市网站建设 地区网站制作 街道网页设计 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器