【发布时间】:2019-02-15 19:47:02
【问题描述】:
我对 yii FrameWork 有点陌生,我需要帮助。
我需要实现一个用于 Stripe 发送的订阅事件的 stripe webhook 控制器。 对于这个控制器,没有视图也没有模型
我可以访问控制器,但是 $_POST 内容是空的,我不知道为什么。
是否可以在没有视图的情况下使用后置动词?
这是一个例子:
class StripeWebhookController extends Controller
{
public function beforeAction($action)
{
if ($action->id == 'index') {
$this->enableCsrfValidation = false;
}
return parent::beforeAction($action);
}
public function actionIndex()
{
header('Content-Type: text/html; charset=utf-8');
StripeLoader::autoload();
\Stripe\Stripe::setApiKey( Settings::get("stripe_secret_key") );
// retrieve the request's body and parse it as JSON
$input = file_get_contents('php://input'); // -> here $input is null
$event_json = json_decode($input, true);
// Do the work...
}
我用过
print_r(Yii::$app->request->post() /*$_POST*/); exit();
我只有一个空数组。
经过几天的搜索,我什么也没找到……
如果有人有想法,我很乐意接受
附加信息:我们在 IIS Web 服务器上运行,使用 Yii2 框架
感谢您阅读我 赛亚
【问题讨论】: