【发布时间】:2012-12-17 14:43:51
【问题描述】:
我想向 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);
我不知道在上面的 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);
还是不行。如果我通过 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 drupal-7 http-headers