我想向https服务器发送POST请求.
$data = 'name=value&name1=value1';
$options = array(
'method' => 'POST',
'data' => $data,
'timeout' => 15,
'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
);
$result = drupal_http_request('http://somewhere.com', $options);
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚在上面的POST示例代码中实现https选项.
有人可以解释一下如何做到这一点吗?我对使用Drupal的PHP编码很新,我绝对可以使用该指南.
我发现所有需要的是在协议中设置它.所以我得到了这段代码.
$data = 'access_token=455754hhnaI&href=fb&template=You have people waiting to play with you, play now!';
$options = array(
'method' => 'POST',
'data' => $data,
'timeout' => 15,
'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
);
$result = drupal_http_request('https://graph.facebook.com/1000721/notifications?', $options);
Run Code Online (Sandbox Code Playgroud)
它仍然无法正常工作.如果我通过Firefox发布https://graph.facebook.com/1000080521/notifications?access_token=45575FpHfhnaI&href=fb&template=You have people waiting to play with you, play now!
它的工作原理.
我可能没有在Drupal中正确构建请求.
我究竟做错了什么?如何让我的代码工作?