Authored by whb

邮件订阅

... ... @@ -42,4 +42,30 @@ class IndexData
$params['client_secret'] = Sign::getSign($params);
return Yohobuy::get(Yohobuy::SERVICE_URL . self::URL_OPERATIONS_RESOURCE_GET, $params);
}
/**
* 邮箱订阅
*
* @param string $email
* @param string $uid
* @return array
*/
public static function emailSubscriber($email, $uid = 0)
{
//TODO 走老接口
// 构建必传参数
$param = Yohobuy::param();
$param['page'] = 1;
$param['open_key'] = '12345';
$param['method'] = 'open.subscriber.subscriber';
$param['email'] = $email;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
unset($param['app_version']);
unset($param['client_type']);
unset($param['os_version']);
unset($param['screen_size']);
unset($param['v']);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
\ No newline at end of file
... ...
... ... @@ -6,6 +6,7 @@ use Plugin\Cache;
use Configs\CacheConfig;
use Api\Yohobuy;
use Plugin\Images;
use Plugin\Helpers;
class CommonController extends WebAction
{
... ... @@ -118,4 +119,24 @@ class CommonController extends WebAction
}
return $this->helpJsonCallbackResult($callback, $data['code'], $data['message'], $banner);
}
/**
* 获取邮件订阅
*
* @return jsonp
*/
public function emailsubscriberAction()
{
$callback = $this->get('callback', '');
$email = $this->get('email', '');
$uid = intval($this->get('uid', '0'));
$data = array();
//验证邮件
if(Helpers::verifyEmail($email)) {
$data = IndexData::emailSubscriber($email, $uid);
return $this->helpJsonCallbackResult($callback, $data['code'], $data['message'], $data['data']);
} else {
return $this->helpJsonCallbackResult($callback, 403, '订阅失败', '');
}
}
}
\ No newline at end of file
... ...