魏长东

weichangdong

qconf 批量添加配置

<?php
//之前是代码写死配置的,要让用qconf,但是一个一个的添加太麻烦,就写这个小工具。把之前代码要用的fb数据抓取信息都添加到qconf里面。

$qzk = new QConfZK("*:2181");
//$value = $qzk->nodeGet("/common/products/wcd/uiver");
//print_r($value) . PHP_EOL;

$app_info_old = [
        9 => ['app_id' => '*******************','token' => '*******************|kdn-***-zuiqCjXkf97I'], //
        8 => ['app_id' => '*******************','token' => '**********************************'], //
		10 => ['app_id' => '*******************','token' => '**********************************'],//
		30001 => ['app_id' => '*******************','token' => '**********************************'],//
        10000 => ['app_id' => '*******************', 'token' => '*******************|***--Ps7EezCrc'],//
        //20000 => ['app_id' => '*******************', 'token' => '**********************************'],//
		20000 => ['app_id' => '*******************', 'token' => '**********************************'],//
		20001 => ['app_id' => '*******************', 'token' => '*******************|alaGob-***-EzLsWG5gxKE'],//
	  20 => ['app_id' => '*******************','token' => '**********************************'],// 
	  21 => ['app_id' => '*******************','token' => '**********************************'],//
      23 => ['app_id' => '*******************','token' => '*******************|***-wuZI'],//
	  10023 => ['app_id' => '*******************','token' => '**********************************'],//
	  24 => ['app_id' => '*******************','token' => '**********************************'],//
	  25 => ['app_id' => '*******************','token' => '**********************************'],//
    ];

$path = '/common/products/';
$all_product = $qzk->list($path);
foreach ($all_product as  $pc) {
	if ($pc != 'wcd_test'){
		//continue;
	}
	$wcd = $qzk->listWithValue($path.$pc);
	$appid = $wcd['appid'];
	if (!isset($app_info_old[$appid])){
		continue;	
	}
	$qzk->nodeSet($path.$pc.'/fb_app_id',$app_info_old[$appid]['app_id']);
	$qzk->nodeSet($path.$pc.'/fb_token',$app_info_old[$appid]['token']);
	$qzk->nodeSet($path.$pc.'/fb_online',1);
	$get_value = $qzk->listWithValue($path.$pc);
	print_r($get_value);
}