- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用来自 http://phphttpclient.com/ 的 Httpful PHP 库,这是我的示例代码:
$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 = Request::post($url)->body($data)->sendsType(Mime::FORM)->send();
var_dump($response);
die();
我的问题是如何添加表单数据。我试图阅读文档,但找不到任何解释,只有发送 xml 和 Json 示例,但我无法在请求中获得带有表单数据的正常 POST。
有人请帮助我..
最佳答案
终于我找到了答案,感谢@Xiquid 指导我找到答案,这是我使用 php httpful rest 客户端发送帖子数据的工作答案:
$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();
关于php - Httpful 发布表单数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27596663/
我一直在开发一个 .NET 字符串格式化库来协助应用程序的本地化。它称为 SmartFormat 并在 GitHub 上开源. 它试图解决的问题之一是 Grammatical Numbers .这也称
leetcode关于单数II的题目是: 给定一个整数数组,除一个元素外,每个元素出现三次。找到那一个。笔记:您的算法应该具有线性运行时复杂度。你能在不使用额外内存的情况下实现它吗? 其实我已经从网站上
我想知道创建/命名模型的首选方法是什么? 我的应用程序有一个“用户”模型,其中包含用于创建、获取、更新(等)用户记录的所有相关业务逻辑。 在我的一些 Controller 中,我可能想要获取多个“用户
在我的 Mysql 数据库中,我有一个术语列表,例如(首字母大写,大多数时候是复数) Hairdressers Restaurants Beauty Salons Fournitures For Re
如果我决定为我的所有路线名称使用复数形式,但某些资源仅作为一个东西存在,您是否将其保持为单数(更直观)或尊重使用复数的决定并保持这种方式? 我们正在用 PHP 为我们的客户门户网站设计一个新的 API
我可能在做一些愚蠢的事情,但是...... 应用/模型/user.rb: class User 然后,当我导航到 /users/123/totem/new 时,出现错误: ActionView::
您能否澄清一些 Matplotlib 术语: “subplots”(或“subplot”?)这个词是“axes”的同义词吗? “轴”和“轴”的单数/复数是什么? 最佳答案 这确实是一个令人困惑的问题。
我有一个 profile我的应用程序中的模型。我想允许用户通过 /profile 查看他们自己的个人资料,所以我创建了这条路线: resource :profile, :only => :show 我
我是一名优秀的程序员,十分优秀!