//测试 内容 固定为 你好  post
$curlPost = 'mobile='.$mobile.'&message='.$message.'&memberId='.$memberid;

$ch = curl_init();
$url='http://www.haibi.com.cn/sendMessage.jsp';
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_USERAGENT, "Jimmy's CURL Example beta");

$data = curl_exec($ch);

curl_close($ch);
echo $data;

//一下是get

$url_get = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$res['AppId'].'&secret='.$res['AppSecret'];
$result = file_get_contents($url_get);
if (empty($result)){
$ch = curl_init();
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_URL, $url_get);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
}
$json = json_decode($result);

curl+ post/get 提交的更多相关文章

  1. CURL 模拟http提交

    1:CURL模拟get提交 private function httpGet($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETUR ...

  2. PHP再学习1——cURL表单提交、HTTP请求和响应分析

    1.前言 最近迷恋WEB方面的技术,虽然自己是一个嵌入式工程师,但是我深知若需要把传感器终端的数据推送至“平台”必然会和WEB技术打交道.在工作中发现嵌入式工程师喜欢 二进制形式的协议,例如MODBU ...

  3. php中curl模拟post提交多维数组(转载)

    原文地址:http://www.cnblogs.com/mingaixin/archive/2012/11/09/2763265.html 今天需要用curl模拟post提交参数,请求同事提供的一个接 ...

  4. cURL模拟POST提交数据

    首先,是这个代码: <?php //curl模拟post提交数据$url = "http://127.0.0.1/immoc/output.php";$post_data = ...

  5. 在php中分别使用curl的post提交数据的方法和get获取网页数据的方法

    在php中分别使用curl的post提交数据的方法和get获取网页数据的方法整理分享一下额,具体代码如下: (1)使用php curl获取网页数据的方法: $ch=curl_init(); //设置选 ...

  6. (转载)PHP 下 CURL 通过 POST 提交表单失败的原因之一与解决办法

    (转载)http://blog.renren.com/share/246611432/7511385884 前几天在学习使用 CURL 时遇到一个问题:在 a.php 中以 POST 方式向 b.ph ...

  7. curl之post提交xml

    直接上代码: /** * 以post方式提交xml到对应的接口url * * @param string $xml 需要post的xml数据 * @param string $url url * @p ...

  8. php通过CURL模拟post提交请求

    <?php header("Content-type:text/html;charset=utf-8"); class Test{ public function reque ...

  9. php CURL 模拟 POST 提交数据

    <?php function liansuo_post($url,$data){ // 模拟提交数据函数 $curl = curl_init(); // 启动一个CURL会话 curl_seto ...

  10. php curl vs python提交多维数组+文件

    总结: 1.data数据格式 2.php post 格式无需json_encode(关联数组,所以可以绕弯)  参考:http://bbs.csdn.net/topics/390645553?page ...

随机推荐

  1. PHP常见方法

    1.获取字符串长度: preg_match_all('/./us', $only, $match); echo count($match[0]); 2.Php除法取整 2.1.round — 对浮点数 ...

  2. mysql 不是主键不能删除的保护问题解决办法?

       select * from t_answerexams;      delete from  t_answerexams  where  selectid = 'c4582502-8b27-44 ...

  3. DDNS -VPN设置方法

    背景分析:一般情况下企业网络都是专线,也就是静态公网IP,但是也有一些是刚起步的小公司和一些网络需求不是很高的企业. 当前,由于公司是刚起步的小公司,网络是PPPOE拨号,但是又是总部和分部分开的,另 ...

  4. ASP.NET中调用存储过程方法

    两种不同的存储过程调用方法 为了突出新方法的优点,首先介绍一下在.NET中调用存储过程的“官方”方法.另外,本文的所有示例程序均工作于SqlServer数据库上,其它情况类似,以后不再一一说明.本文所 ...

  5. mysql Can't connet MySQL server to '@localhost'

    10063/10060/10038好像都能解决 mysql -nt -remove mysql -nt install

  6. LINQ to SQL快速上手 step by step

    Step1:建立数据库      在使用Linq to Sql前,我们要将相应的数据库建好.在这个Demo中,使用的数据库是SQL Server Express 2005.      我们首先建立一个 ...

  7. {Reship}{C#}{GDI+}GDI+画笔,线,区域类型

    =================================================================================== This article is ...

  8. linux C学习笔记05--信号量与共享内存(进程同步)

    花了半天时间把信号量与共享内存整合到了一起,先来看信号量代码,semaphore.c 当中sem_P()和sem_V()函数分别为信号量等待和信号量释放. 两个进程同时访问共享内存,为了避免发生同时读 ...

  9. oVirt-engine项目UI结构

    1.管理面板文件路径 ovirt-engine/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmi ...

  10. webform注册和Repeater

    一.注册1.日期(1)年月日用三DropDownList个,分别循环写入数字 代码写在后台  Page_Load中的代码 if (IsPostBack == false) { //年绑定数据 ; i- ...