亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

正在回答

2 回答

我的http_curl函數參數順序和老師的有點不一樣。

protected function http_curl($url, $arr = '', $type = 'get', $res = 'json')
??? {
??????? $ch = curl_init();
??????? curl_setopt($ch, CURLOPT_URL, $url);
??????? curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
??????? if ($type == 'post') {
??????????? curl_setopt($ch, CURLOPT_POST, 1);
??????????? curl_setopt($ch, CURLOPT_POSTFIELDS, $arr);
??????? }
??????? $output = curl_exec($ch);
??????? if ($res == 'json') {
??????????? if ($err = curl_errno($ch)) {
??????????????? //要在關閉之前獲得curl_errno
??????????????? curl_close($ch);
??????????????? return $err;
??????????? } else {
??????????????? return json_decode($output, true);
??????????? }
??????? }
??? }

0 回復 有任何疑惑可以回復我~

這個問題很簡單,你不需要完全按照視頻的來。

//2.組裝群發接口數據array
??????? // 下列數組用于測試打印json格式群發消息
??????? /*
??????? {
??????? "touser":"OPENID",
??????? "mpnews":{
??????? "media_id":"123dsdajkasd231jhksad"
??????? },
??????? "msgtype":"mpnews"
??????? }
???????? */
??????? // $arr=array(
??????? //???? 'touser'=>'oW_5b1Tmhp6kpzuuffe9a1AFn7cE',
??????? //???? 'text'=>array('content'=>'歡迎關注,有事沒事常聯系。'),
??????? //???? 'msgtype'=>'text'
??????? // );
??????? // //3.將array->轉json
??????? // $postJson=json_encode($arr);

??????? $postJson = '{
??????????? "touser":"oW_5b1Tmhp6kpzuuffe9a1AFn7cE",
??????????? "text":{"content":"歡迎關注,有事沒事常聯系。"},
??????????? "msgtype":"text"
??????? }';
??????? //4.調用curl
??????? $res = $this->http_curl($url, $postJson, 'post');

$postJson只需要是json就可以,里面的字符可以是中文的。

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

中文顯示成了ASCII

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號