小编BLV*_*BLV的帖子

如何使用drupal_http_request构建https POST请求?

我想向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中正确构建请求.

我究竟做错了什么?如何让我的代码工作?

https http-headers drupal-7

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

drupal-7 ×1

http-headers ×1

https ×1