how to construct an https POST request with drupal_http_request?

回眸只為那壹抹淺笑 提交于 2019-12-04 12:44:20

There is no difference between using drupal_http_request() with a secure connection (https://), or without a secure connection (http://).

PHP must be compiled with support for OpenSSL; otherwise, drupal_http_request() doesn't support secure connections. Apart that, the only issue could be the proxy server not supporting a secure connection.

As side note, you are using https://graph.facebook.com/1000721/notifications? as URL for the request. The question mark should not be part of the URL.

I would also use drupal_http_build_query() to build the data to use for the request.

$data = array(
  'access_token' => '455754hhnaI',
  'href' => 'fb',
  'template' => 'You have people waiting to play with you, play now!'
);

$options = array(
  'method' => 'POST',
  'data' => drupal_http_build_query($data),
  'timeout' => 15,
  'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
);

$result = drupal_http_request('https://graph.facebook.com/1000721/notifications', $options);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!