fix: phan 메시지에 따라 수정
- array에 +=를 phan 알아듣기 쉽게 array_merge로 - Util::array_get이 더 이상 필요없으므로 null coalescing - array로 tuple류를 반환하는 함수에 index를 포함하도록 변경 - php intelephense에게는 현재 무효 - getPost 일부 값에 int 지정 - 아이템에 id property를 없앴으므로 관련 코드 제거 - enum은 array key로 사용할 수 없으므로 \Ds\Map으로 변경 - KakaoKey PhanRedefineClass 에러 우회
This commit is contained in:
@@ -173,7 +173,7 @@ $serverID = $emperior['server_id'] ?? ($emperior['serverID'] ?? null);
|
||||
if (!$nation['nation'] ?? null) {
|
||||
continue;
|
||||
}
|
||||
$nation += Json::decode($nation['data']);
|
||||
$nation = array_merge(Json::decode($nation['data']), $nation);
|
||||
|
||||
/** @var array $nation */
|
||||
$nation['typeName'] = getNationType($nation['type']);
|
||||
@@ -201,7 +201,7 @@ $serverID = $emperior['server_id'] ?? ($emperior['serverID'] ?? null);
|
||||
}
|
||||
|
||||
if (key_exists('aux', $nation) && !is_array($nation['aux'])) {
|
||||
$nation += Json::decode($nation['aux']);
|
||||
$nation = array_merge(Json::decode($nation['aux']), $nation);
|
||||
}
|
||||
|
||||
echo $templates->render('oldNation', $nation);
|
||||
|
||||
@@ -110,7 +110,8 @@ if ($scenarioIdx && key_exists($scenarioIdx, $scenarioList[$seasonIdx] ?? [])) {
|
||||
|
||||
$hallResult = array_map(function ($general) use ($typeValue, $ownerNameList) {
|
||||
$aux = Json::decode($general['aux']);
|
||||
$general += $aux;
|
||||
/** @var array $general */
|
||||
$general = array_merge($aux, $general);
|
||||
|
||||
if (key_exists($general['owner'], $ownerNameList)) {
|
||||
$general['ownerName'] = $ownerNameList[$general['owner']];
|
||||
@@ -118,10 +119,11 @@ if ($scenarioIdx && key_exists($scenarioIdx, $scenarioList[$seasonIdx] ?? [])) {
|
||||
|
||||
if (!key_exists('bgColor', $general)) {
|
||||
if (!key_exists('color', $general)) {
|
||||
$general['bgColor'] = GameConst::$basecolor4;
|
||||
$color = GameConst::$basecolor4;
|
||||
} else {
|
||||
$general['bgColor'] = $general['color'];
|
||||
$color = $general['color'];
|
||||
}
|
||||
$general['bgColor'] = $color;
|
||||
}
|
||||
|
||||
if (!key_exists('fgColor', $general)) {
|
||||
|
||||
+4
-3
@@ -882,9 +882,9 @@ function generalInfo2(General $generalObj)
|
||||
</table>";
|
||||
}
|
||||
|
||||
function getOnlineNum()
|
||||
function getOnlineNum(): int
|
||||
{
|
||||
return KVStorage::getStorage(DB::db(), 'game_env')->online;
|
||||
return KVStorage::getStorage(DB::db(), 'game_env')->getValue('online') ?? 0;
|
||||
}
|
||||
|
||||
function onlinegen(General $general)
|
||||
@@ -1075,6 +1075,7 @@ function updateTraffic()
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$admin = $gameStor->getValues(['year', 'month', 'refresh', 'maxonline', 'maxrefresh']);
|
||||
/** @var array{year:int,month:int,refresh:int,maxonline:int,maxrefresh:int} $admin */
|
||||
|
||||
//최다갱신자
|
||||
$user = $db->queryFirstRow('select name,refresh from general order by refresh desc limit 1');
|
||||
@@ -2248,7 +2249,7 @@ function calcCityDistance(int $from, int $to, ?array $linkNationList): ?int
|
||||
* @param $from 기준 도시 코드
|
||||
* @param $to 대상 도시 코드
|
||||
* @param $linkNationList 경로에 해당하는 국가 리스트
|
||||
* @return array $dist=>[cityID, $nation] 배열 가장 앞이 가장 가까움
|
||||
* @return array<int,array{int,int}[]> $dist=>[cityID, $nation] 배열 가장 앞이 가장 가까움
|
||||
*/
|
||||
function searchDistanceListToDest(int $from, int $to, array $linkNationList)
|
||||
{
|
||||
|
||||
+5
-5
@@ -8,11 +8,11 @@ class MapRequest{
|
||||
public $neutralView;
|
||||
public $showMe;
|
||||
function __construct($obj){
|
||||
$this->serverID = Util::array_get($obj['serverID'], null);
|
||||
$this->year = Util::array_get($obj['year']);
|
||||
$this->month = Util::array_get($obj['month']);
|
||||
$this->aux = Util::array_get($obj['aux'],[]);
|
||||
$this->neutralView = Util::array_get($obj['neutralView'], false);
|
||||
$this->serverID = $obj['serverID'] ?? null;
|
||||
$this->year = $obj['year'] ?? null;
|
||||
$this->month = $obj['month'] ?? null;
|
||||
$this->aux = $obj['aux'] ?? [];
|
||||
$this->neutralView = $obj['neutralView'] ?? false;
|
||||
$this->showMe = $obj['showMe'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ function getTournament(int $tnmt)
|
||||
][$tnmt] ?? "TOURNAMENT_TYPE_ERR_{$tnmt}";
|
||||
}
|
||||
|
||||
function printRow($k, $npc, $name, $abil, $tgame, $win, $draw, $lose, $gd, $gl, $prmt)
|
||||
function printRow(int $k, int $npc, string $name, $abil, $tgame, $win, $draw, $lose, $gd, $gl, $prmt)
|
||||
{
|
||||
$k += 1;
|
||||
if ($prmt > 0) {
|
||||
@@ -588,7 +588,10 @@ function fillLowGenAll($tnmt_type)
|
||||
//7 8강
|
||||
//8 4강
|
||||
//9 결승
|
||||
function getTwo($tournament, $phase)
|
||||
/**
|
||||
* @return array{0:int,1:int}
|
||||
*/
|
||||
function getTwo(int $tournament, int $phase): array
|
||||
{
|
||||
$cand = [];
|
||||
switch ($tournament) {
|
||||
|
||||
@@ -6,6 +6,7 @@ include "func.php";
|
||||
|
||||
WebUtil::requireAJAX();
|
||||
|
||||
/** @var int|null */
|
||||
$pick = Util::getPost('pick', 'int');
|
||||
|
||||
if(!$pick){
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ $loader->addClassMap((function () {
|
||||
|
||||
|
||||
//디버그용 매크로
|
||||
ini_set("session.cache_expire", 10080); // minutes
|
||||
ini_set("session.cache_expire", "10080"); // minutes
|
||||
|
||||
ob_start();
|
||||
|
||||
|
||||
@@ -191,6 +191,7 @@ class GetConst extends \sammo\BaseAPI
|
||||
|
||||
public function genConstData()
|
||||
{
|
||||
/** @var array<string,array{0:string,1:string[],2?:int> */
|
||||
$gameConstKeys = [
|
||||
'nationType' => [
|
||||
'\sammo\buildNationTypeClass',
|
||||
|
||||
@@ -15,10 +15,6 @@ class BaseItem implements iAction{
|
||||
protected $buyable = false;
|
||||
protected $reqSecu = 0;
|
||||
|
||||
function getID(){
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
function getRawName(){
|
||||
return $this->rawName;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class BaseStatItem extends BaseItem{
|
||||
protected $rawName = '노기';
|
||||
protected $consumable = false;
|
||||
protected $buyable = true;
|
||||
|
||||
|
||||
protected const ITEM_TYPE = [
|
||||
'명마'=>['통솔', 'leadership'],
|
||||
'무기'=>['무력', 'strength'],
|
||||
@@ -27,7 +27,6 @@ class BaseStatItem extends BaseItem{
|
||||
$this->rawName = $nameTokens[$tokenLen-1];
|
||||
[$this->statNick, $this->statType] = static::ITEM_TYPE[$nameTokens[$tokenLen-3]];
|
||||
|
||||
$this->id = $this->statValue;
|
||||
$this->name = sprintf('%s(+%d)',$this->rawName, $this->statValue);
|
||||
$this->info = sprintf('%s +%d', $this->statNick, $this->statValue);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace sammo;
|
||||
|
||||
use Ds\Map;
|
||||
use sammo\DTO\BettingInfo;
|
||||
use sammo\DTO\BettingItem;
|
||||
use sammo\Enums\RankColumn;
|
||||
@@ -346,12 +347,13 @@ class Betting
|
||||
$db = DB::db();
|
||||
|
||||
if ($this->info->reqInheritancePoint) {
|
||||
/** @var UserLogger[] */
|
||||
$loggers = [];
|
||||
/** @var Map<int,UserLogger> */
|
||||
$loggers = new Map();
|
||||
foreach ($rewardList as $rewardItem) {
|
||||
if ($rewardItem['userID'] === null) {
|
||||
continue;
|
||||
}
|
||||
/** @var int */
|
||||
$userID = $rewardItem['userID'];
|
||||
$amount = $rewardItem['amount'];
|
||||
|
||||
@@ -373,7 +375,7 @@ class Betting
|
||||
$partialText = "베팅 부분 당첨({$matchPoint}/{$selectCnt})";
|
||||
}
|
||||
|
||||
if (key_exists($userID, $loggers)) {
|
||||
if ($loggers->hasKey($userID)) {
|
||||
$userLogger = $loggers[$userID];
|
||||
} else {
|
||||
$userLogger = new UserLogger($userID);
|
||||
|
||||
@@ -15,8 +15,7 @@ use function \sammo\getTechAbil;
|
||||
use function sammo\getTechLevel;
|
||||
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
use sammo\MustNotBeReachedException;
|
||||
|
||||
class che_징병 extends Command\GeneralCommand
|
||||
{
|
||||
@@ -98,6 +97,9 @@ class che_징병 extends Command\GeneralCommand
|
||||
$maxCrew = $leadership * 100;
|
||||
|
||||
$reqCrewType = GameUnitConst::byID($this->arg['crewType']);
|
||||
if($reqCrewType === null){
|
||||
throw new MustNotBeReachedException();
|
||||
}
|
||||
if ($reqCrewType->id == $currCrewType->id) {
|
||||
$maxCrew -= $general->getVar('crew');
|
||||
}
|
||||
|
||||
@@ -158,6 +158,8 @@ class che_출병 extends Command\GeneralCommand
|
||||
|
||||
$candidateCities = [];
|
||||
|
||||
$currDist = 999;
|
||||
|
||||
$minDist = Util::array_first_key($distanceList);
|
||||
do {
|
||||
//1: 최단 거리 도시 중 공격 대상이 있는가 확인
|
||||
|
||||
@@ -165,7 +165,7 @@ class RaiseInvader extends \sammo\Event\Action
|
||||
->setNPCType(9)
|
||||
->setStat(Util::toInt($specAvg * 1.8), Util::toInt($specAvg * 1.8), Util::toInt($specAvg * 1.2))
|
||||
->setAffinity(999)
|
||||
->setExpDed($exp * 1.2, null)
|
||||
->setExpDed(Util::toInt($exp * 1.2), null)
|
||||
->setGoldRice(99999, 99999);
|
||||
$ruler->build($env);
|
||||
|
||||
|
||||
@@ -415,7 +415,7 @@ class General implements iAction
|
||||
* @param bool $withStatAdjust 능력치간 보정 사용 여부
|
||||
* @param bool $useFloor 내림 사용 여부, false시 float 값을 반환할 수도 있음
|
||||
*
|
||||
* @return int|float 계산된 능력치
|
||||
* @return float 계산된 능력치
|
||||
*/
|
||||
|
||||
protected function getStatValue(string $statName, $withInjury = true, $withIActionObj = true, $withStatAdjust = true, $useFloor = true): float
|
||||
@@ -1130,7 +1130,7 @@ class General implements iAction
|
||||
|
||||
/**
|
||||
* @param ?int[] $generalIDList
|
||||
* @param null|string|RankColumn[] $column
|
||||
* @param null|array<string|RankColumn> $column
|
||||
* @param int $constructMode
|
||||
* @return \sammo\General[]
|
||||
* @throws MustNotBeReachedException
|
||||
|
||||
+16
-14
@@ -11,12 +11,9 @@ class GeneralAI
|
||||
{
|
||||
/** @var General */
|
||||
protected $general;
|
||||
/** @var array */
|
||||
protected $city;
|
||||
/** @var array */
|
||||
protected $nation;
|
||||
/** @var int */
|
||||
protected $genType;
|
||||
protected array $city;
|
||||
protected array $nation;
|
||||
protected int $genType;
|
||||
|
||||
/** @var AutorunGeneralPolicy */
|
||||
protected $generalPolicy;
|
||||
@@ -90,13 +87,12 @@ class GeneralAI
|
||||
$this->env = $gameStor->getAll(true);
|
||||
$this->baseDevelCost = $this->env['develcost'] * 12;
|
||||
$this->general = $general;
|
||||
if ($general->getRawCity() === null) {
|
||||
$city = $general->getRawCity();
|
||||
if ($city === null) {
|
||||
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID());
|
||||
$general->setRawCity($city);
|
||||
$this->city = $city;
|
||||
} else {
|
||||
$this->city = $general->getRawCity();
|
||||
}
|
||||
$this->city = $city;
|
||||
|
||||
$this->nation = $db->queryFirstRow(
|
||||
'SELECT nation,name,color,capital,capset,gennum,gold,rice,bill,rate,rate_tmp,scout,war,strategic_cmd_limit,surlimit,tech,power,level,chief_set,type,aux FROM nation WHERE nation = %i',
|
||||
@@ -866,7 +862,7 @@ class GeneralAI
|
||||
|
||||
$userGenerals = $this->userCivilGenerals;
|
||||
if (in_array($this->dipState, [self::d평화, self::d선포])) {
|
||||
$userGenerals += $this->userWarGenerals;
|
||||
$userGenerals = array_merge($this->userWarGenerals, $userGenerals);
|
||||
}
|
||||
|
||||
$generalCandidates = [];
|
||||
@@ -1142,7 +1138,7 @@ class GeneralAI
|
||||
|
||||
$npcGenerals = $this->npcCivilGenerals;
|
||||
if (in_array($this->dipState, [self::d평화, self::d선포])) {
|
||||
$npcGenerals += $this->npcWarGenerals;
|
||||
$npcGenerals = array_merge($this->npcWarGenerals, $npcGenerals);
|
||||
}
|
||||
|
||||
$generalCandidates = [];
|
||||
@@ -3826,16 +3822,23 @@ class GeneralAI
|
||||
|
||||
|
||||
$picked = false;
|
||||
|
||||
/** @var General|null */
|
||||
$randGeneral = null;
|
||||
foreach (Util::range(5) as $idx) {
|
||||
|
||||
/** @var General */
|
||||
if ($this->npcWarGenerals) {
|
||||
/** @var General */
|
||||
$randGeneral = Util::choiceRandom($this->npcWarGenerals);
|
||||
} else if ($this->npcCivilGenerals) {
|
||||
/** @var General */
|
||||
$randGeneral = Util::choiceRandom($this->npcCivilGenerals);
|
||||
} else if ($this->userWarGenerals) {
|
||||
/** @var General */
|
||||
$randGeneral = Util::choiceRandom($this->userWarGenerals);
|
||||
} else if ($this->userCivilGenerals) {
|
||||
/** @var General */
|
||||
$randGeneral = Util::choiceRandom($this->userCivilGenerals);
|
||||
} else {
|
||||
break;
|
||||
@@ -3863,11 +3866,10 @@ class GeneralAI
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$picked || !$randGeneral) {
|
||||
if (!$picked || $randGeneral === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/** @var General $randGeneral */
|
||||
$randGeneral->setVar('officer_level', $chiefLevel);
|
||||
$randGeneral->setVar('officer_city', 0);
|
||||
$randGeneral->applyDB($db);
|
||||
|
||||
@@ -24,6 +24,7 @@ class che_도시치료 extends BaseGeneralTrigger{
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
/** @var array{int,string,string}[] $patients */
|
||||
$patients = $db->queryAllLists(
|
||||
'SELECT no,name,nation FROM general WHERE city=%i AND injury > 10 AND no != %i',
|
||||
$general->getCityID(),
|
||||
@@ -39,6 +40,7 @@ class che_도시치료 extends BaseGeneralTrigger{
|
||||
|
||||
$cureList = [];
|
||||
|
||||
/** @var string|null */
|
||||
$curedPatientName = null;
|
||||
foreach($patients as [$patientID, $patientName, $patientNationID]){
|
||||
if (!Util::randBool(0.5)) {
|
||||
@@ -56,6 +58,10 @@ class che_도시치료 extends BaseGeneralTrigger{
|
||||
return $env;
|
||||
}
|
||||
|
||||
if($curedPatientName === null){
|
||||
throw new \sammo\MustNotBeReachedException();
|
||||
}
|
||||
|
||||
|
||||
if(count($cureList) == 1){
|
||||
$josaUl = JosaUtil::pick($curedPatientName, "을");
|
||||
|
||||
@@ -285,14 +285,13 @@ class InheritancePointManager
|
||||
}
|
||||
|
||||
//FIXME: 굳이 merge, apply, clean 3단계를 거쳐야 할 이유가 없음
|
||||
/** @var array[InheritanceKey]float */
|
||||
$rebirthDegraded = [
|
||||
InheritanceKey::dex => 0.5,
|
||||
];
|
||||
/** @var Map<InheritanceKey,float> */
|
||||
$rebirthDegraded = new Map();
|
||||
$rebirthDegraded[InheritanceKey::dex] = 0.5;
|
||||
|
||||
$inheritStor = KVStorage::getStorage(DB::db(), "inheritance_{$userID}");
|
||||
$totalPoint = 0;
|
||||
/** @var array[InheritanceKey][float, string|float] */
|
||||
/** @var array<string,array{0:float,1:string|float}> */
|
||||
$allPoints = $inheritStor->getAll();
|
||||
if (!$allPoints || count($allPoints) == 0) {
|
||||
//비었으므로 리셋 안함
|
||||
@@ -309,7 +308,7 @@ class InheritancePointManager
|
||||
|
||||
foreach ($allPoints as $rKey => [$value,]) {
|
||||
$key = InheritanceKey::from($rKey);
|
||||
if ($isRebirth && key_exists($key, $rebirthDegraded)) {
|
||||
if ($isRebirth && $rebirthDegraded->hasKey($key)) {
|
||||
$value *= $rebirthDegraded[$key];
|
||||
}
|
||||
$keyText = $this->getInheritancePointType($key)->info;
|
||||
|
||||
@@ -375,9 +375,9 @@ class Scenario{
|
||||
'npcNeutral_cnt'=>count($this->getNPCneutral()),
|
||||
'nation'=>array_map(function($nation) use ($nationGeneralCnt, $nationGeneralExCnt, $nationGeneralNeutralCnt){
|
||||
$brief = $nation->getBrief();
|
||||
$brief['generals'] = Util::array_get($nationGeneralCnt[$nation->getID()], 0);
|
||||
$brief['generalsEx'] = Util::array_get($nationGeneralExCnt[$nation->getID()], 0);
|
||||
$brief['generalsNeutral'] = Util::array_get($nationGeneralNeutralCnt[$nation->getID()], 0);
|
||||
$brief['generals'] = $nationGeneralCnt[$nation->getID()] ?? 0;
|
||||
$brief['generalsEx'] = $nationGeneralExCnt[$nation->getID()] ?? 0;
|
||||
$brief['generalsNeutral'] = $nationGeneralNeutralCnt[$nation->getID()] ?? 0;
|
||||
|
||||
return $brief;
|
||||
},$this->getNation())
|
||||
|
||||
@@ -25,15 +25,15 @@ class Nation{
|
||||
private $generals = [];
|
||||
|
||||
public function __construct(
|
||||
int $id = null,
|
||||
string $name = '국가',
|
||||
string $color = '#000000',
|
||||
int $gold = 0,
|
||||
int $rice = 2000,
|
||||
string $infoText = '국가 설명',
|
||||
int $tech = 0,
|
||||
?string $type = null,
|
||||
int $nationLevel = 0,
|
||||
int $id = null,
|
||||
string $name = '국가',
|
||||
string $color = '#000000',
|
||||
int $gold = 0,
|
||||
int $rice = 2000,
|
||||
string $infoText = '국가 설명',
|
||||
int $tech = 0,
|
||||
?string $type = null,
|
||||
int $nationLevel = 0,
|
||||
array $cities = []
|
||||
){
|
||||
$this->id = $id;
|
||||
@@ -47,7 +47,7 @@ class Nation{
|
||||
$this->nationLevel = $nationLevel;
|
||||
$this->cities = $cities;
|
||||
|
||||
if(count($cities)){
|
||||
if(count($this->cities)){
|
||||
$this->capital = $this->cities[0];
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ class Nation{
|
||||
else{
|
||||
$capital = 0;
|
||||
}
|
||||
|
||||
|
||||
if($this->type === null){
|
||||
$type = Util::choiceRandom(GameConst::$availableNationType);
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class Nation{
|
||||
|
||||
$nationStor->scout_msg = $this->infoText;
|
||||
|
||||
|
||||
|
||||
$diplomacy = [];
|
||||
foreach($otherNations as $nation){
|
||||
$diplomacy[] = [
|
||||
@@ -143,7 +143,7 @@ class Nation{
|
||||
if(count($diplomacy) > 0){
|
||||
$db->insert('diplomacy', $diplomacy);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function addGeneral(GeneralBuilder $general){
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace kakao;
|
||||
|
||||
if (class_exists('\\kakao\\KakaoKey') === false) {
|
||||
// @suppress PhanRedefineClass
|
||||
class KakaoKey
|
||||
{
|
||||
const REST_KEY = '';
|
||||
const ADMIN_KEY = '';
|
||||
const REDIRECT_URI = '';
|
||||
}
|
||||
class KakaoKeyNull
|
||||
{
|
||||
const REST_KEY = '';
|
||||
const ADMIN_KEY = '';
|
||||
const REDIRECT_URI = '';
|
||||
}
|
||||
|
||||
if (!class_exists('\\kakao\\KakaoKey')) {
|
||||
class_alias('\\kakao\\KakaoKeyNull', '\\kakao\\KakaoKey');
|
||||
}
|
||||
//https://devtalk.kakao.com/t/php-rest-api/14602/3
|
||||
//header('Content-Type: application/json; charset=utf-8');
|
||||
@@ -46,7 +48,7 @@ class Story_Path
|
||||
|
||||
class Talk_Path
|
||||
{
|
||||
public static $TALK_PROFILE= "/v1/api/talk/profile";
|
||||
public static $TALK_PROFILE = "/v1/api/talk/profile";
|
||||
public static $TALK_TO_ME = "/v2/api/talk/memo/send";
|
||||
public static $TALK_TO_ME_DEFAULT = "/v2/api/talk/memo/default/send";
|
||||
}
|
||||
@@ -77,12 +79,12 @@ class Kakao_REST_API_Helper
|
||||
}
|
||||
|
||||
self::$admin_apis = array(
|
||||
User_Management_Path::$USER_IDS,
|
||||
Push_Notification_Path::$REGISTER,
|
||||
Push_Notification_Path::$TOKENS,
|
||||
Push_Notification_Path::$DEREGISTER,
|
||||
Push_Notification_Path::$SEND
|
||||
);
|
||||
User_Management_Path::$USER_IDS,
|
||||
Push_Notification_Path::$REGISTER,
|
||||
Push_Notification_Path::$TOKENS,
|
||||
Push_Notification_Path::$DEREGISTER,
|
||||
Push_Notification_Path::$SEND
|
||||
);
|
||||
}
|
||||
|
||||
public function request($api_path, $params = '', $http_method = 'GET')
|
||||
@@ -94,7 +96,7 @@ class Kakao_REST_API_Helper
|
||||
$requestUrl = ($api_path == '/oauth/token' ? self::$OAUTH_HOST : self::$API_HOST) . $api_path;
|
||||
|
||||
if (($http_method == 'GET' || $http_method == 'DELETE') && !empty($params)) {
|
||||
$requestUrl .= '?'.$params;
|
||||
$requestUrl .= '?' . $params;
|
||||
}
|
||||
|
||||
$opts = [
|
||||
@@ -167,25 +169,25 @@ class Kakao_REST_API_Helper
|
||||
{
|
||||
$this->AUTHORIZATION_CODE = $authorization_code;
|
||||
$params = [
|
||||
'grant_type'=>'authorization_code',
|
||||
'client_id'=>$this->REST_KEY,
|
||||
'redirect_uri'=>$this->REDIRECT_URI,
|
||||
'code'=>$this->AUTHORIZATION_CODE
|
||||
];
|
||||
'grant_type' => 'authorization_code',
|
||||
'client_id' => $this->REST_KEY,
|
||||
'redirect_uri' => $this->REDIRECT_URI,
|
||||
'code' => $this->AUTHORIZATION_CODE
|
||||
];
|
||||
$result = $this->_create_or_refresh_access_token($params);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function refresh_access_token($refresh_token)
|
||||
{
|
||||
$params = [
|
||||
'grant_type'=>'refresh_token',
|
||||
'client_id'=>$this->REST_KEY,
|
||||
'refresh_token'=>$refresh_token
|
||||
];
|
||||
'grant_type' => 'refresh_token',
|
||||
'client_id' => $this->REST_KEY,
|
||||
'refresh_token' => $refresh_token
|
||||
];
|
||||
$result = $this->_create_or_refresh_access_token($params);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -212,11 +214,11 @@ class Kakao_REST_API_Helper
|
||||
public function meWithEmail()
|
||||
{
|
||||
$params = [
|
||||
'property_keys'=>'['.
|
||||
'"id",'.
|
||||
'"kakao_account.has_email","kakao_account.email",'.
|
||||
'"kakao_account.is_email_valid","kakao_account.is_email_verified"'.
|
||||
']'
|
||||
'property_keys' => '[' .
|
||||
'"id",' .
|
||||
'"kakao_account.has_email","kakao_account.email",' .
|
||||
'"kakao_account.is_email_valid","kakao_account.is_email_verified"' .
|
||||
']'
|
||||
];
|
||||
return $this->request(User_Management_Path::$ME);
|
||||
}
|
||||
@@ -257,8 +259,8 @@ class Kakao_REST_API_Helper
|
||||
public function talk_to_me_default($req)
|
||||
{
|
||||
$params = [
|
||||
'template_object' => json_encode($req)
|
||||
];
|
||||
'template_object' => json_encode($req)
|
||||
];
|
||||
return $this->request(Talk_Path::$TALK_TO_ME_DEFAULT, $params, 'POST');
|
||||
}
|
||||
|
||||
@@ -269,7 +271,7 @@ class Kakao_REST_API_Helper
|
||||
|
||||
|
||||
private $REST_KEY = KakaoKey::REST_KEY; // 디벨로퍼스의 앱 설정에서 확인할 수 있습니다.
|
||||
private $REDIRECT_URI = KakaoKey::REDIRECT_URI; // 설정에 등록한 사이트 도메인 + redirect uri
|
||||
private $AUTHORIZATION_CODE = ''; // 동의를 한 후 발급되는 code
|
||||
private $REFRESH_TOKEN = '';
|
||||
private $REDIRECT_URI = KakaoKey::REDIRECT_URI; // 설정에 등록한 사이트 도메인 + redirect uri
|
||||
private $AUTHORIZATION_CODE = ''; // 동의를 한 후 발급되는 code
|
||||
private $REFRESH_TOKEN = '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user