如果 "http://www.baidu.com/api/api.php?time=".$time."&token=".token 不是你噫造的话,那么请遵守人家的规则

解决方案 »

  1.   

    client.php$key='123456789';//双方约定并保密
    $time = time();
    $token = md5($key.$time);
    $data = file_get_contents("http://www.baidu.com/api/api.php?time=".$time."&token=".$token);
    $result = json_decode($data, true);if($result['success']){
    echo 'success';
    }else{
    echo 'fail';
    }
    api.php$time = isset($_GET['time'])? $_GET['time'] : '';
    $token= isset($_GET['token'])? $_GET['token'] : '';
    $key = '123456789';//与上面保持一样$ret = array();if(md5($key.$time)==$token){
    $ret['success'] = true;
    }else{
    $ret['success'] = false;
    }header('content-type:application/json;charset=utf8');echo json_encode($ret);