PHP发送Websocket消息 - GoEasy PubSub

本节内容为PHP实现GoEasy Rest接口发送消息, 使用时,可参阅Rest接口的详细介绍

PHP

$url = 'http(s)://<REST Host>/publish';  


$post_data = array("appkey"=>"BC-xxxxxxxxx","channel"=>$channel,"content"=>$content);

echo php_ajax($url,$post_data);


function php_ajax($url, $post_data) {
  $postdata = http_build_query($post_data);
  $options = array(
    'http' => array(
      'method' => 'POST',
      'header' => 'Content-type:application/x-www-form-urlencoded',
      'content' => $postdata,
      'timeout' => 15 * 60 
    )
  );
  $context = stream_context_create($options);
  $result = file_get_contents($url, false, $context);

  return $result;
}

REST Host

杭州: rest-hangzhou.goeasy.io
新加坡: rest-singapore.goeasy.io

results matching ""

    No results matching ""