当前位置: 首页 > 工具软件 > Httpful > 使用案例 >

php处理post表单数据,php – Httpful post表单数据

长孙阳成
2023-12-01

最后我找到了答案,感谢@Xiquid引导我找到答案,这是我使用php httpful rest client发送帖子数据的工作答案:

$google_redirect = $request->getSchemeAndHttpHost().$this->generateUrl('myroutename')."?platform=google";

$url = "https://www.googleapis.com/oauth2/v3/token";

$data = array(

'code' => $request->query->get('code'),

'client_id' => $this->container->getParameter('GOOGLE_CLIENT_ID'),

'client_secret' => $this->container->getParameter('GOOGLE_CLIENT_SECRET'),

'redirect_uri' => $google_redirect,

'grant_type' => "authorization_code"

);

$response = RestRequester::post($url)

->method(Http::POST) // Alternative to Request::post

->withoutStrictSsl() // Ease up on some of the SSL checks

->expectsJson() // Expect HTML responses

->sendsType(Mime::FORM)

->body('grant_type=authorization_code&code='.$data['code']."&client_id=".$data['client_id']."&client_secret=".$data['client_secret']."&redirect_uri=".$data['redirect_uri'])

->send();

var_dump($response);

die();

 类似资料: