云服务器网:购买云服务器和VPS必上的网站!

php如何做cdn加速

php如何做cdn加速php做cdn加速的案例:在对应的php文件中添加以下代码:function sendURL($push_url_data,$url = http://push.dnion.com/cdnUrlPush.do){$ch = curl_in

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);

?>

本文来源:https://www.yuntue.com/post/79108.html | 云服务器网,转载请注明出处!

关于作者: yuntue

云服务器(www.yuntue.com)是一家专门做阿里云服务器代金券、腾讯云服务器优惠券的网站,这里你可以找到阿里云服务器腾讯云服务器等国内主流云服务器优惠价格,以及海外云服务器、vps主机等优惠信息,我们会为你提供性价比最高的云服务器和域名、数据库、CDN、免费邮箱等企业常用互联网资源。

为您推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注