|
@@ -17,7 +17,7 @@ use Symfony\Component\Cache\Adapter\RedisAdapter;
|
|
*/
|
|
*/
|
|
class WatchController extends Controller
|
|
class WatchController extends Controller
|
|
{
|
|
{
|
|
- use WeChat;
|
|
|
|
|
|
+// use WeChat;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 处理微信消息
|
|
* 处理微信消息
|
|
@@ -172,6 +172,62 @@ class WatchController extends Controller
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 编辑标签
|
|
|
|
+ * @param $account_name
|
|
|
|
+ * @param $tag_name
|
|
|
|
+ * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
|
+ */
|
|
|
|
+ public static function userAddTag($account_name, $open_id, $tag)
|
|
|
|
+ {
|
|
|
|
+ $app = self::getApp($account_name);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $re = $app->user_tag->tagUsers([$open_id], $tag);
|
|
|
|
+ return $re;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 移除标签
|
|
|
|
+ * @param $account_name
|
|
|
|
+ * @param $open_id
|
|
|
|
+ * @param $tag
|
|
|
|
+ * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
|
|
|
+ * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
|
+ * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
|
+ */
|
|
|
|
+ public static function userDelTag($account_name, $open_id, $tag)
|
|
|
|
+ {
|
|
|
|
+ $app = self::getApp($account_name);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $re = $app->user_tag->untagUsers([$open_id], $tag);
|
|
|
|
+ return $re;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param $account_name
|
|
|
|
+ * @return \EasyWeChat\OfficialAccount\Application
|
|
|
|
+ */
|
|
|
|
+ public static function getApp($account_name){
|
|
|
|
+ $account = self::getAccount($account_name);
|
|
|
|
+ $app = Factory::officialAccount($account['settings']);
|
|
|
|
+// $cache = new RedisAdapter(app('redis')->connection()->client());
|
|
|
|
+// $app->rebind('cache', $cache);
|
|
|
|
+ return $app;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function getAccount($val)
|
|
|
|
+ {
|
|
|
|
+ if (is_numeric($val)) {
|
|
|
|
+ return Account::byIdGetModel($val);
|
|
|
|
+ }
|
|
|
|
+ return Account::byNameGetModel($val);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 处理微信消息【自动】
|
|
* 处理微信消息【自动】
|