php脚本获取网络数据

来源:互联网 发布:淘宝客清退 编辑:程序博客网 时间:2024/06/05 00:12

使用php脚本调用url接口进行数据对接时,调用用法:

#!/usr/bin/php -q
<?php

@ini_set('default_socket_timeout', 1);

set_time_limit(1); //设置程序执行时间(为0时,执行直到程序结束)

$arg = $argv[1];

$url="http://ip/index.htm?blah=1&gaga=$arg";
if($hd = fopen($url, 'r'))
{
$data = fread($hd, 1000);
}
fclose($hd);

if($data)
{
echo "data is $data\n";
}
else
{
echo "fail to get data\n";
}
?>
原创粉丝点击