Commit e13dd1e5 authored by 杨培's avatar 杨培

增加多个API

Client 返回值判断优化
parent 36f8f41a
......@@ -10,7 +10,7 @@ use internalApi\code\Medal;
require __DIR__.'/_init.php';
Medal::setDebug(true);
$ret = Medal::getUserMedals(10);
//Medal::setDebug(true);
$ret = Medal::countUserMedals(8);
print_r($ret);
\ No newline at end of file
var_dump($ret);
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 2017/6/28
* Time: 15:26
*/
use internalApi\xue\Favorite;
require __DIR__.'/_init.php';
Favorite::setDebug(true);
//$count = Favorite::countUserFavorites(8);
//var_dump($count);
$count = \internalApi\xue\Comment::getLikeMsgCount(8);
var_dump($count);
\ No newline at end of file
......@@ -72,7 +72,7 @@ class Client
foreach (['clientId', 'clientSecret', 'apiUrl'] as $prop) {
if ($this->$prop === null) {
throw new ClientException(static::class." initialize failed, \${$prop} not set!");
throw new ClientException("InternalApi $name initialize failed, \${$prop} not set!");
}
}
......@@ -111,7 +111,7 @@ class Client
if ($httpCode == 403 && substr($response, 0, 6) === 'error:') {
$message = substr($response, 6);
throw new ClientException("接口 $api 调用失败: " . $message);
} elseif ($httpCode != 200 || !$response) {
} elseif ($httpCode != 200 || $response === false) {
throw new ClientException('接口请求异常', $httpCode);
}
......
......@@ -13,9 +13,9 @@ return [
'clientSecret' => 'Kuy2dVHKRWKAFRXX2l6k'
],
'xue' => [
'apiUrl' => 'http://u.yunya.com/test/api-server',
'apiUrl' => 'http://ct.yunya.com/api',
'clientId' => 'common',
'clientSecret' => 'Kuy2dVHKRWKAFRXX2l6k'
'clientSecret' => 'Z2oKgZYYc8mznesYMf1o'
],
'code' => [
'apiUrl' => 'http://dev.wxherr.com/site/api-server',
......
......@@ -5,23 +5,20 @@ namespace internalApi\code;
use internalApi\base\Client;
/**
* Created by PhpStorm.
* User: pader
* Date: 2017/6/28
* Time: 12:00
* 扳手快查勋章 API
*/
class Medal extends Client
{
/**
* 获取扳手快查用户获得的勋章列表
* 获取扳手快查用户拥有的勋章数量
*
* @param $uid
* @return array
* @return int
*/
public static function getUserMedals($uid)
public static function countUserMedals($uid)
{
return self::call('medal.getUserMedals', compact('uid'));
return self::call('medal.countUserMedals', compact('uid'));
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 2017/6/28
* Time: 15:47
*/
namespace internalApi\xue;
use internalApi\base\Client;
class Comment extends Client
{
public static function getLikeMsgCount($uid)
{
return self::call('comment.getLikeMsgCount', compact('uid'));
}
public static function getReplyMsgCount($uid)
{
return self::call('comment.getReplyMsgCount', compact('uid'));
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: pader
* Date: 2017/6/28
* Time: 15:24
*/
namespace internalApi\xue;
use internalApi\base\Client;
class Favorite extends Client
{
/**
* 获取用户学院收藏数量
*
* @param $uid
* @return int
*/
public static function countUserFavorites($uid)
{
return self::call('favorite.countUserFavorite', compact('uid'));
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment