0
点赞
收藏
分享

微信扫一扫

PHP post请求

醉东枫 2022-04-06 阅读 86
php
<?php
    $keytext = $_REQUEST["keywordtext"]; //关键词
    
    $guojia = $_REQUEST["guojia"]; //国家代码

    $xianlu = $_REQUEST["xianlu"]; //线路

	$shendu = $_REQUEST["shendu"]; //挖掘深度

ini_set('max_execution_time', 600);

// post参数
 function send_post($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' => 150 * 600 // 超时时间(单位:s)

    )

  );

  $context = stream_context_create($options);

  $result = file_get_contents($url, false, $context);

  

  return $result;

}
// post参数

$post_data = array(

  'text' => $keytext,

  'regions' => $guojia,

  'shendu' => $shendu

);

echo send_post('http://www.123456.top/getKeyword.php', $post_data);

array的数据和URL链接传送一样例如原文text和regions两个就是下面一样

http://www.123456.top/getKeyword.php?text=登山靴&regions=jp
举报

相关推荐

0 条评论