public function test_newslist()
 {
     $urlbase = C("HTTP_HOST") . "/app/movie/newslist";
     //验证用户ID
     $this->assert_is_true(send_get_success($urlbase));
     //id为空
     $this->assert(40002, send_get($urlbase . "?id=d")->errcode);
     //id非整数
     $this->assert_is_true(send_get_success($urlbase . "?id=1"));
     //id为整数
     //验证mfields字符串
     $this->assert(40099, send_get($urlbase . "?mfields=id,name22,alias")->errcode);
     $this->assert(40099, send_get($urlbase . "?id=1&mfields=id,name22,alias")->errcode);
     $this->assert_is_true(send_get_success($urlbase . "?id=1&mfields=id,alias"));
     $this->assert_is_true(send_get_success($urlbase . "?id=1&mfields=id,mname,alias"));
     //验证nfields字符串
     $this->assert(40099, send_get($urlbase . "?id=1&nfields=id,title22,content")->errcode);
     $this->assert_is_true(send_get_success($urlbase . "?id=1&nfields=id,content"));
     $this->assert_is_true(send_get_success($urlbase . "?id=1&nfields=id,title,content"));
     //验证分页
     $this->assert(40002, send_get($urlbase . '?pager={"limit":2,dd"page":1,"order":"id desc"}')->errcode);
     //pager参数不合法
     //$this->assert(40002,send_get($urlbase.'?pager={"limit":2,dd"page":1,"order":"id desc"}')->errcode);//pager参数排序不合法
     $this->assert_is_true(send_get_success($urlbase . '?pager={"limit":2,"page":1,"order":"id%20desc"}'));
     //合法的pager
 }
Esempio n. 2
0
function send_get_success($url)
{
    return send_get($url)->success;
}
Esempio n. 3
0
<?php

include 'api_common.inc.php';
$timestamp = time() * 1000;
//debug
if (!empty($_GET['fid'])) {
    exit(urlencode(base64_encode(des_encrypt("{$_GET['fid']}|{$timestamp}0|username", $TRIPLEDES_KEY, $TRIPLEDES_IV))));
}
if (empty($_GET['encode_profile']) || empty($_GET['name']) || empty($_GET['username']) || empty($_GET['token'])) {
    exit('Missing encode_profile/name/username/token');
}
$encode_profile = trim($_GET['encode_profile']);
$name = trim($_GET['name']);
$encodeArr = explode('|', des_decrypt(base64_decode($encode_profile), $TRIPLEDES_KEY, $TRIPLEDES_IV));
if (sizeof($encodeArr) != 3 || $encodeArr[2] != $_GET['username'] || $encodeArr[1] < $timestamp) {
    exit('Unauthorized or out-of-date');
}
$url = API_CLOUDPLAY . "/private/2/file/{$encodeArr[0]}/download_url?download_inner=0&download_expire=864000";
$rs = json_decode(send_get($url), 1);
if (!empty($rs['data'])) {
    $rs['data'] = str_replace('http://sw3.pplive.cn', '', $rs['data']);
    $rs['data'] = str_replace('http://swift.pplive.cn', '', $rs['data']);
    if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") || strpos($_SERVER["HTTP_USER_AGENT"], 'rv:11')) {
        $name = urlencode(urlencode($name));
    } else {
        $name = urlencode($name);
    }
    $rs['data'] = str_replace('.ppc?', ".ppc.{$name}.mp4?", $rs['data']);
    header("Location: {$rs['data']}");
}
Esempio n. 4
0
<?php

include 'api_common.inc.php';
if (empty($_POST['username']) || empty($_POST['apikey'])) {
    ajaxReturn('', 'username,apikey can not be empty', 403);
}
//验证apikey,获取上传url
$url = SVC_PPTVYUN . '/api/picurlwithtoken';
$params = array('username' => $_POST['username'], 'apitk' => md5($_POST['apikey'] . $url));
$arr = json_decode(send_get($url . '?' . http_build_query($params)), 1);
if (empty($arr['data'])) {
    ajaxReturn('', 'apikey认证失败', 403);
}
//获取上传图片的url
$newUrl = 'http://ppyun.ugc.upload.pptv.com/php/uploadPic.php';
$uploadPicUrl = str_replace('http://api.grocery.pptv.com/upload_file.php', $newUrl, $arr['data']);
$uploadPicUrl = str_replace('http://api.grocery.ppqa.com/upload_file.php', $newUrl, $uploadPicUrl);
if (empty($_POST['uploadpic'])) {
    $uploadPicUrl = '';
}
//算出登录的token
$session_data = array('username' => $_POST['username'], 'apikey' => $_POST['apikey'], 'expire_time' => time() + 86400);
$token = urlencode(base64_encode(des_encrypt(http_build_query($session_data), $TRIPLEDES_KEY, $TRIPLEDES_IV)));
$data = array('nextUrl' => "{$URL_PREFIX}/initUpload.php", 'uploadPicUrl' => $uploadPicUrl, 'token' => $token);
ajaxReturn($data, 'success', 0);
Esempio n. 5
0
function getProjects($config)
{
    echo send_get($config['apiURL'] . "/api/projects/" . $config['_projectId'] . "/tasks", $config['access_token']);
}
Esempio n. 6
0
include 'api_common.inc.php';
if (empty($_SERVER['argv'])) {
    exit;
}
$fid = $_SERVER['argv'][1];
$ppFeature = $_SERVER['argv'][2];
$file_size_arr = explode('_', $ppFeature);
$file_size = $file_size_arr[0];
$fileArray = big_file_array($ppFeature);
$md5 = strtoupper(big_file_md5($fileArray));
$url = API_CLOUDPLAY . "/1/file/{$fid}/md5?fromcp=private_cloud&feature_pplive={$ppFeature}&md5={$md5}";
$json1 = send_post($url);
$xunlei_cid = big_file_cid($fileArray, $file_size);
$xunlei_gcid = big_file_gcid($fileArray, $file_size);
$url = API_CLOUDPLAY . "/1/file/{$fid}/features?fromcp=private_cloud&feature_pplive={$ppFeature}";
$json2 = send_json_post($url, '{"feature_xunlei_cid":"' . $xunlei_cid . '","feature_xunlei_gcid":"' . $xunlei_gcid . '"}');
//删除临时文件
$target = UPLOAD_DIR . "/{$ppFeature}";
delDirAndFile($target);
//必须,否则文件无法进入转码队列
$url = API_CLOUDPLAY . "/2/file/{$fid}/action/uploadrange?feature_pplive={$ppFeature}&segs=1";
sleep(30);
$json3 = send_get($url);
$arr3 = json_decode(send_get($url), 1);
if (empty($arr3['data']) || $arr3['data']['status'] == 50) {
    sleep(30);
    $json3 = send_get($url);
    $json3 = 'retry';
}
$phpPath = __DIR__ . '/0x0000.log';
file_put_contents($phpPath, " {$md5} \n {$xunlei_cid} \n {$xunlei_gcid} \n {$json1} \n {$json2} \n {$json3} \n ");
Esempio n. 7
0
if (empty($session)) {
    ajaxReturn('', 'token error', 403);
}
//获取上传进度
$url = API_CLOUDPLAY . "/1/file/{$_POST['fid']}/uploading?fromcp=private_cloud";
$json = send_get($url);
$return = json_decode($json, 1);
if (empty($return['data']) || empty($return['data']['fileSize'])) {
    ajaxReturn('', '公有云接口出错', 500);
}
//获取上传范围
$url = API_CLOUDPLAY . "/2/file/{$_POST['fid']}/action/uploadrange?fromcp=private_cloud&feature_pplive={$_POST['ppfeature']}&segs=1&asyncMD5=true";
if (!$IS_LOCAL) {
    $url .= '&inner=true';
}
$json = send_get($url);
$rangeRs = json_decode($json, 1);
//如果已经上传完成,提交md5和feature
if ($return['data']['fileSize'] == $return['data']['finished']) {
    //cli模式下异步提交最后的md5和feature
    $cacheDir = UPLOAD_DIR . "/cache/{$_POST['ppfeature']}";
    if (is_dir($cacheDir)) {
        $binPath = strpos(PHP_OS, 'WIN') === false ? '/usr/local/php5/bin/php' : 'D:\\wamp\\bin\\php\\php5.5.12\\php.exe';
        $binPath = $IS_LOCAL[0] == 'localhost.idc.pplive.cn' ? '/usr/local/php5.5.27/bin/php' : $binPath;
        $phpPath = __DIR__ . "/api_cli_curl.php {$_POST['fid']} {$_POST['ppfeature']}";
        pclose(popen("{$binPath} {$phpPath} &", 'r'));
    }
    api_cache($_POST['ppfeature'], null);
} else {
    if (empty($rangeRs['data']) || empty($rangeRs['data']['ranges'])) {
        ajaxReturn('', '公有云接口出错', 500);
 public function test_modifypassword()
 {
     $urlBase = C("HTTP_HOST") . "/app/user/modifypassword";
     $urlRegister = C("HTTP_HOST") . "/app/user/register";
     $urlVerifyphonenumber = C("HTTP_HOST") . "/app/user/sendsmsverify";
     $this->assertEquals(400, send_get($urlBase)->errcode);
     //参数不能为空
     //$this->assertEquals(40001,send_get($urlBase."?phonenumber=18220512014")->errcode);   //传phonenumber必须传code
     //$this->assertEquals(40001,send_get($urlBase."?phonenumber=18220512014&code=2014")->errcode);   //参数newpassword不能为空
     $this->assertEquals(400, send_get($urlBase . "?phonenumber=18220512014")->errcode);
     //参数newpassword不能为空
     $this->assertEquals(304, send_get($urlBase . "?phonenumber=1850924952&newpassword=123456")->errcode);
     //使用了非法的phonenumber
     $newphonenumber = "185" . (20000000 + rand(0, 9999999));
     $code = substr($newphonenumber, strlen($newphonenumber) - 4);
     $this->assertEquals(201, send_get($urlBase . "?phonenumber=" . $newphonenumber . "&newpassword=123456")->errcode);
     //该手机号没有对应的帐号信息
     //注册
     $this->assertEqualsTrue(send_get_success($urlVerifyphonenumber . "?phonenumber=" . $newphonenumber));
     //获取一次验证码
     $userID = send_get($urlRegister . "?phonenumber=" . $newphonenumber . "&password=123456&code=" . $code . "&registrationid=05086381974")->data;
     $this->assertEquals(202, send_get($urlBase . "?phonenumber=" . $newphonenumber . "&newpassword=123456")->errcode);
     //新密码不能和原密码相同
     //$this->assertEquals(40101, send_get($urlBase."?phonenumber=".$newphonenumber."&code=dddf&newpassword=654321")->errcode); //短信验证码错误
     $this->assertEqualsTrue(send_get_success($urlBase . "?phonenumber=" . $newphonenumber . "&newpassword=654321"));
     //通过
     $this->assertEquals(200, send_get($urlBase . "?oldpassword=123456&newpassword=123456")->errcode);
     //帐号未登录
     $this->assertError(300, $urlBase . "?oldpassword=123456&newpassword=123456&authuserid=ddf");
     //用户ID格式不正确
     $this->assertEquals(204, send_get($urlBase . "?oldpassword=123456&newpassword=123456&authuserid=" . $userID)->errcode);
     //原密码错误
     $this->assertEquals(202, send_get($urlBase . "?oldpassword=654321&newpassword=654321&authuserid=" . $userID)->errcode);
     //新密码不能和原密码相同
     $this->assertEqualsTrue(send_get_success($urlBase . "?oldpassword=654321&newpassword=123456&authuserid=" . $userID));
     //通过
 }