12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace Home\Controller;
- use Think\Controller;
- class PushWarnController extends Controller {
-
-
- public function s_curl($url){
- $ch = curl_init();
- curl_setopt ($ch, CURLOPT_URL, $url);
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
- $file_contents = curl_exec($ch);
- curl_close($ch);
- $arr = json_decode($file_contents,true);
- return $arr;
- }
- public function curl($url,$data=''){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $info = curl_exec($ch);
- if (curl_errno($ch)) {return 'Errno'.curl_error($ch);}else{ return $info;}
- curl_close($ch);
- }
-
- /**
- * [array_column1 ] 多维数组改成关联数组转字符串,
- * @param $rows [description]必需。多维数组。
- * @param [type] $column_key [description]必需。可以是索引数组的列的整数索引,或者是关联数组的列的字符串键值。
- * @param [type] $index_key [description]可选。用作返回数组的索引/键的列。
- * @return [type] [description](两个参数)返回用逗号分割的字符串,(三个参数)返回以第三个参数为列的索引数组
- */
- function array_column1($rows, $column_key, $index_key = null) {
- $data = array();
- if (empty($index_key)) {
- foreach ($rows as $row) {
- $data[] = $row[$column_key];
- }
- $data=implode(",",$data);
- } else {
- foreach ($rows as $row) {
- $data[$row[$index_key]] = $row[$column_key];
- }
- }
- return $data;
- }
- }
|