function startProcess($db) { $businessComfirmUrl = Yii::app()->params['orderUrl'] . "update/order/business-confirm-order"; $time = time(); $formatTime = date('Y-m-d H:i:s', $time); try { //查找订单 $payTime = $time - 1800; $sql = "SELECT b.business_id,o.order_sn from " . get_tables('business_info') . " as b left join " . get_tables('order_info') . " as o on b.business_id=o.business_id WHERE b.express_type in (2, 11, 12) and o.order_status=1 and o.express_type > 0 and o.pay_time <= " . $payTime . " LIMIT 100"; $data = $db->createCommand($sql)->queryAll(); if (!empty($data)) { foreach ($data as $k => $v) { $post = ['business_id' => $v['business_id'], 'order_sn' => $v['order_sn'], 'user_id' => 1, 'user_name' => 'jiaoben', 'source' => 'autoStockUp']; $return = curlPost($businessComfirmUrl, $post); if ($return['code'] != 0) { addLog("data:" . json_encode($return, JSON_UNESCAPED_UNICODE) . '|time:' . $formatTime); echo $v['order_sn'] . ":fail" . "\r\n"; } else { echo $v['order_sn'] . ":success" . "\r\n"; } } echo "data update:" . count($data) . "\r\n"; } else { echo "no data \r\n"; } echo 'finish'; } catch (Exception $e) { $msg = "filename:autoStockUp|functionname:start_process|error:" . $e->getMessage() . "|time:" . $formatTime; echo $msg . "\r\n"; addLog($msg); } }
public function index() { if (IS_GET) { $this->display('index'); } else { $id = $_POST['project_id']; if ($_POST['type'] == 1) { $data = M('ProjectAttach')->where(array('project_id' => $id))->getField('investor_id', true); } else { if ($_POST['type'] == 2) { $data = M('ProjectInvestor')->where(array('project_id' => $id, 'status' => array(array('egt', 4), array('elt', 8), 'AND')))->getField('investor_id', true); } else { if ($_POST['type'] == 3) { $data = M('ProjectInvestor')->where(array('project_id' => $id, 'status' => 9))->getField('investor_id', true); } } } if ($data) { $phones = M('UsersDetail')->where(array('id' => array('in', $data), 'phone' => array('neq', '')))->getField('phone', true); $phonelist = implode(',', $phones); $count = count($phones); $mac = md5(NOW_TIME . C('SMSKEY')); $info = array('phone' => $phonelist, 'count' => $count, 'content' => $_POST['content'], 'time' => NOW_TIME, 'mac' => $mac); $url = 'http://www.dreammove.cn/Sms/sendsms.html'; $ret = curlPost($url, $info); if ($ret == 1) { $this->success('短信发送成功。' . $ret); } else { $this->error('短信发送失败。' . $ret); } } } }
/** * @param $params * @return bool */ public function getCommand($params) { $mnc = new MNC(); $post = array('channelId' => $params['channelId'], 'fee' => $params['fee'], 'ip' => $params['ip'], 'extra' => $params['order_id'], 'imsi' => $params['imsi'], 'gameName' => $params['app_name'], 'chargeName' => $params['iap_name']); $interface_url = 'http://121.41.58.237:8981/center/getCommand.sys'; $mac = $post['channelId'] . $post['fee'] . $post['ip'] . $post['extra'] . urlencode($post['gameName']) . urlencode($post['chargeName']) . $mnc->ctcc_config['key']; $post['mac'] = strtoupper(md5($mac)); $code = curlPost($interface_url, $post); //json $code_arr = json_decode($code, true); $msg = $code_arr + $params; $msg['timestamp'] = $_SERVER['REQUEST_TIME']; $msg['sign'] = md5($msg['app_id'] . $msg['iap_id'] . $msg['fee'] . $msg['order_id'] . $msg['behavior_status'] . $msg['timestamp']); //写日志 /*M('Logs')->add(array( 'created'=>TIME, 'title'=>'getCommand', 'content'=>$code, ));*/ //消息加密 $msg = Aviup::encrypt(json_encode($msg)); $code_arr = json_decode($code, true); $resultCode = $code_arr['resultCode']; if ($resultCode == '0000') { $this->ajaxReturn(array('status' => 0, 'msg' => $msg), 'JSON', JSON_UNESCAPED_UNICODE); } else { //失败原因加入订单 $error_text = Aviup::encrypt(json_encode(array('errordescription' => $mnc->ctcc_error[$resultCode], 'order_id' => $params['order_id']), JSON_UNESCAPED_UNICODE)); M('Statistics')->where(array('id' => $params['order_id']))->setField(array('fail_reasion' => $error_text)); $this->ajaxReturn(array('status' => 1, 'msg' => $error_text), 'JSON', JSON_UNESCAPED_UNICODE); } return true; }
function updataKml($kmls, $starttime, $file = '', $source = 1, $topic) { //访问API $kmlUpdateApi = getConfig('kmlUpdateApi'); $unique = unique_arr($kmls); //去重 //print_r($unique);exit; $soadata = formatApiData($unique); //去重 $returnData = curlPost($kmlUpdateApi, array('data' => $soadata)); logs($returnData, 1, 'consumer', $topic); print_r($returnData); exit; //logs(' Access :'.$kmlUpdateApi, 1, 'consumer',$topic); //logs(' Params is:'.json_encode($data), 1, 'consumer',$topic); //logs(' Return is:'.$returnData, 1, 'consumer',$topic); $cachePath = getconfig('kmlCachePath'); $cacheBack = getconfig('kmlCacheBak'); //验证还回结果 $objs = json_decode($returnData); if (empty($returnData) || $objs->status != 0 || empty($objs->data)) { if ($source == 2) { $dir = $cacheBack . '/' . date('Y-m-d') . '/' . $topic; mkFolder($dir); $toPath = $dir . '/' . basename($file); moveFile($file, $toPath); logs(date('H:i:s') . ' API error:' . $objs->msg . '; file:' . $file . ' has move to ' . $toPath, 1, 'consumer', $topic); } else { if ($objs->status < 3) { $cacheTopicPath = $cachePath . '/' . $topic; mkFolder($cacheTopicPath); $filename = basename($file); $source = $cacheTopicPath . '/' . $filename; file_put_contents($source, $data); logs(date('H:i:s') . ' API error:' . $objs->msg . '; file:' . $file . ' has backup to ' . $source, 1, 'consumer', $topic); } else { $backFile = $cacheBack . '/' . basename($file); moveFile($file, $backFile); logs(date('H:i:s') . ' API error:' . $objs->msg . '; file ' . basename($file) . 'has move to ' . $backFile, 1, 'consumer', $topic); } } } if ($source == 2) { if (file_exists($file)) { unlink($file); } } $arr = object2Array($objs); $returnKml = $arr['data']; $insertNum = 0; if ($source == 1) { $insertNum = addKml($returnKml, $kmls, $topic); } logs('kafka num:' . count($kmls) . ',send data num:' . count($unique) . ', API return:' . count($returnKml) . ',insertNum:' . $insertNum . ',Time: ' . getTime($starttime), 1, 'consumer', $topic); $kmls = ''; }
public function imgUploadAlbum($gid, $aid, $imageURL, $imageText) { $imageText = str_replace(' ', '%20', $imageText); $data = array("file1" => "@" . $this->imgSave($imageURL)); $server = api("photos.getUploadServer", "album_id={$aid}&group_id={$gid}"); $res = curlPost($server->response->upload_url, $data); $upload = json_decode($res); $save = api("photos.save", "group_id={$gid}&caption={$imageText}&album_id={$upload->aid}&server={$upload->server}&photos_list={$upload->photos_list}&hash={$upload->hash}"); return $save; //return $save->response[0]->id; }
function sendCallDoneInfo($request, $stage) { global $apiurl; global $agentid; $callduration = getValueFromArray($request, 'callduration'); $status = getValueFromArray($request, 'status'); $recordurl = getValueFromArray($request, 'data'); $message = getValueFromArray($request, 'message'); $data = array("callduration" => $callduration, "status" => $status, "recordurl" => $data, "message" => $message, "stage" => $stage, "agent" => $agentid, "type" => "nextcall"); curlPost($apiurl . '/api/agent.php', $data); }
public function getinfo() { if (IS_GET) { $mac = md5($_GET['time'] . C('SMSKEY')); if ($mac != $_GET['mac']) { return false; } $data = array('userid' => 416, 'account' => 'HY-jmzc', 'password' => 'Hj1234', 'action' => 'overage'); // 短信发送 $ret = curlPost($this->url, $data); header("Content-type:text/xml;charset=utf-8"); echo $ret; } }
<?php /** * 客户端测试代码 */ $data = array('method' => 'save', 'index' => 'test', 'key' => 1, 'field' => array('testid' => rand(1, 9999), 'value' => '这里是值')); $data = json_encode($data); $rst = curlPost("http://192.168.1.203/Psearch/", $data); echo $rst; exit; function curlPost($url, $data = array(), $ref = '', $timeout = 10, $header = "") { $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_REFERER, $ref); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, "Psearch-Client"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); $result = curl_exec($ch); curl_close($ch); return $result; }
public function insert() { $login_pass = getRandomNum(8); $data['login_user'] = I('post.mobile'); $data['login_pass'] = md5($login_pass); $member = M('Member')->where(array('login_user' => $data['login_user']))->find(); if ($member) { $this->error('会员已经存在', '?c=Shop&a=add'); } $data['type'] = 1; $member_id = M('Member')->add($data); if ($member_id < 1) { $this->error('服务器忙,请稍侯尝试', '?c=Shop&a=add'); } $_account = 'cf_zcsd'; $_password = '******'; $_url = 'http://106.ihuyi.cn/webservice/sms.php?method=Submit&format=json'; $data = array('account' => $_account, 'password' => $_password, 'mobile' => $login_user, 'content' => '亲爱的客户大大,您的吆喝密码是【' . $login_pass . '】 小的马不停蹄给您送来了,敬请笑纳,么么哒!'); $res_json = curlPost($_url, $data, 5); $model = D('Shop'); if ($model->create()) { $filelist = $this->getUploads(); foreach ($filelist as $item) { //$data[$item['key']] = $item['savepath'].$item['savename']; $model->__set($item['key'], $item['savepath'] . $item['savename']); } $shop_id = $model->add(); if ($shop_id !== false) { $data = array(); $data['shop_id'] = $shop_id; $keywords = $_POST['keywords']; //I('post.keywords'); foreach ($keywords as $title) { if (empty($title)) { continue; } $data['title'] = $title; M('ShopKeywords')->add($data); } $return['msg'] = '数据保存成功!'; $this->success($return['msg'], '?c=Shop&a=contract&id=' . $shop_id); } else { $return['msg'] = '数据写入错误!'; $this->error($return['msg'], '?c=Shop&a=add'); } } else { $return['msg'] = $model->getError(); $this->error($return['msg'], '?c=Shop&a=add'); } }
<?php require 'base.php'; $url = "http://114.215.189.210/api.php/Api/Public/about"; $post_data = array(); $oupput = curlPost($url, $post_data); print_r($oupput);
if (isset($find['data'])) { $curl = ['code' => 200, 'data' => $find['data']]; } else { $curl = curlPost($post_data, $redirect_url); } $date = date('Y/m/d H:i:s') . ' +0000'; $mail = $_GET['email']; if (strstr($curl['data'], "transStatus=Success")) { $database['myorderbox']->insert(['id' => $_GET['ref'], 'data' => $curl['data']]); $success = true; } } else { if ($pingback->isCancelable()) { $checksum = generateChecksum($productId, $price, $price, 'N', $rkey, $key); $post_data = 'transid=' . $productId . '&status=N&rkey=' . $rkey . '&checksum=' . $checksum . '&sellingamount=' . $price . '&accountingamount=' . $price; $curl = curlPost($post_data, $redirect_url); $curl['code'] = 1001; } } header('HTTP/1.1 ' . $curl['code']); $insert = apc_store('transid-' . $productId, $curl['data'], 3600); if ($curl['code'] == 200 && $success) { if ($insert) { echo 'OK'; } else { print_r($insert); } } elseif ($curl['code'] == 1001) { echo 'OK'; } else { print_r($response);
/** * 支持https的访问 */ function curl_fopen($url, $limit = 0, $post = array(), $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 20, $block = TRUE) { $__times__ = isset($_GET['__times__']) ? intval($_GET['__times__']) + 1 : 1; if ($__times__ > 2) { return ''; } $url .= (strpos($url, '?') === FALSE ? '?' : '&') . "__times__={$__times__}"; $return = ''; $matches = parse_url($url); if (isset($matches['host']) && isset($matches['scheme'])) { $return = curlPost($url, $post, $timeout); } return $return; }
$questions[] = array( 'question' => 'Kilala bilang "Huseng Batute"', 'options' => array('Apolinario Mabini', 'Jose Corazon de Hesus', 'Gregorio H. del Pilar', 'Melchora Aquino'), 'answer' => 1 ); $questions[] = array( 'question' => 'What is the national flower of the Philippines?', 'options' => array('Sampaguita', 'Rose', 'Ilang Ilang', 'Daisy'), 'answer' => 0 ); $questions[] = array( 'question' => 'Who of the following explorers arrived in the Philippines in 1521?', 'options' => array('Aubrey', 'Jaynard', 'Elaine', 'Marko'), 'answer' => 0 );*/ #$arr = json_decode(file_get_contents('http://*****:*****@192.168.20.75/engage/api/mchoice/dtl/id/quiz/format/json'),TRUE); $quiz_type_id = $_POST['type']; $topic_id = $_POST['topic_id']; $num_of_q = $_POST['qnum']; $status = $_POST['status']; $loadQuesDtl = array('type' => $quiz_type_id, 'topic_id' => $topic_id, 'qnum' => $num_of_q, 'status' => $status); // $loadQuesUrl='http://*****:*****@162.209.21.251/engage_cms/engage/api/quizsql/loadquestion/'; $loadQuesUrl = $basePath . '/loadQuestion/'; $loadQuesDb = curlPost($loadQuesDtl, $loadQuesUrl); $questions = json_decode($loadQuesDb, TRUE); #$rand_questions = ($questions);//array('questions' => $questions); $arr = array('questions' => $questions); echo json_encode($arr);
<?php // CREATING A MATCH require "init.php"; $matchid = $_POST['matchid']; $currentRound = $_POST['currRound']; $scoreFindDtl = array('match_id' => $matchid, 'round' => $currentRound); $scoreFindUrl = 'http://*****:*****@162.209.21.251/engage_cms/engage/api/quizsql/findScoreId/'; $scoreFindDb = curlPost($scoreFindDtl, $scoreFindUrl); $row = json_decode($scoreFindDb, TRUE); //$score_position=serialize($row[0]['score_position']); //$score_value=intval($row[0]['score_value']); //$score_answer=intval($row[0]['score_answer']); //$score = array(); //$score[$score_position]=array('score'=>$score_value,'answer'=>$score_answer); $score = array(); foreach ($row as $r) { $sp = $r['score_position']; $sv = intval($r['score_value']); $sa = intval($r['score_answer']); $score[$sp] = array('score' => $sv, 'answer' => $sa); } $status = 'success'; echo json_encode($score);
<?php // CREATING A MATCH require "init.php"; $matchid = $_POST['matchid']; $round = $_POST['currRound']; $position = $_POST['position']; $score = $_POST['score']; $answer = $_POST['answer']; $status = 'pending'; $scoreInsertDtl = array('matchid' => $matchid, 'round' => $round, 'position' => $position, 'score' => $score, 'answer' => $answer); // $scoreInsertUrl='http://*****:*****@162.209.21.251/engage_cms/engage/api/quizsql/insertScore/'; $scoreInsertUrl = $basePath . '/insertScore/'; $scoreInsertDb = curlPost($scoreInsertDtl, $scoreInsertUrl); $status = $scoreInsertDb == true ? "success" : ""; $arr = array('status' => $status); echo json_encode($arr);
public function delete_site($idsite = NULL) { $data = array("idsite" => $idsite); echo curlPost("http://localhost/protelindo/api/site/delete", $data); }
<?php require __DIR__ . "/../lib.php"; require __DIR__ . "/../logic.php"; $config = (include __DIR__ . "/../config.php"); function curlPost($url, $file) { $ch = curl_init(); if (!is_resource($ch)) { return false; } curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $file); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); $response = curl_exec($ch); curl_close($ch); return $response; } $filename = "data.bin"; $json = ["appid" => "4", "time" => "1435093393", "type" => "GETJOB", "customField" => []]; $json_string = json_encode($json, true); $data = openssl_encrypt($json_string, $config['cipherTypeDecryption'], $config["keyDecryption"], true); $url = "http://www.vd27-test.com/fw/api.php"; echo var_export(curlPost($url, encrypt($data, $config)), true);
/** * 设置授权方的选项信息 * 该API用于设置授权方的公众号的选项信息,如:地理位置上报,语音识别开关,多客服开关。注意,设置各项选项设置信息,需要有授权方的授权,详见权限集说明。 * @param $token * @return mixed */ public static function set($token) { /* * 请求参数说明 * component_appid 第三方平台appid * authorizer_appid 授权公众号appid * option_name 选项名称 * option_value 设置的选项值 */ /* * POST数据示例 * { * "component_appid":"appid_value", * "authorizer_appid": " auth_appid_value ", * "option_name": "option_name_value", * "option_value":"option_value_value" * } */ /* * 结果参数说明 * errcode 错误码 * errmsg 错误信息 */ /* * 返回结果示例 * { * "errcode":0, * "errmsg":"ok" * } */ /* * 选项名和选项值表 * option_name 选项值说明 * location_report 地理位置上报选项 0 无上报 1 进入会话时上报 2 每5s上报 * voice_recognize 语音识别开关选项 0 关闭语音识别 1 开启语音识别 * customer_service 多客服开关选项 0 关闭多客服 1 开启多客服 */ $url = 'https://api.weixin.qq.com/cgi-bin/component/ api_set_authorizer_option?component_access_token=' . $token; $param = ['component_appid' => '', 'authorizer_appid' => '', 'option_name' => '', 'option_value' => '']; $callback = curlPost($url, $param); return $callback; }
function uploadFrontPageBanner($courseID, $fileName) { $apiUrl = "courses/" . $courseID . "/files"; $apiParams = "name=" . $fileName . ".jpg&content_type=image/jpeg&parent_folder_path=/images&url=" . $_SESSION['template_wizard_url'] . "/resources/images/" . $courseID . "_" . $fileName . ".jpg&on_duplicate=overwrite"; $response = curlPost($apiUrl, $apiParams); return $response; }
$key = "15fdeq7buepvssh8z899rusa6ynxufyn"; $m = new Xcrypt(substr($key, 0, 16), 'cbc', substr($key, 16, 16)); $postData["passwd"] = $m->encrypt($md, 'hex'); $header = array(); $header[] = "serveToken:" . microtime(1); $header[] = "apiKey:1kg8tunzfxt8zvzpf53vjr5es45lvszh"; $str = curlPost($api, $header, $postData); if (!isset($str["accessToken"])) { exit("用户登录验证失败!\n"); } else { echo "用户登录验证成功!\n"; } $header[] = "accessToken:" . $str["accessToken"]; $header[] = "sessionToken:" . $str["sessionToken"]; foreach ($jihuaArr as $value) { $api = "https://api.e.360.cn/2.0/group/getIdListByCampaignId"; $params = array("format" => "json", "campaignId" => intval($value["id"])); $str = curlPost($api, $header, $params); if (!isset($str["groupIdList"])) { echo $value["title"] . " 未获取到分组\n"; continue; } $groupIds = $str["groupIdList"]; /* 开始查询下具体的分组信息 */ $api = "https://api.e.360.cn/2.0/group/getInfoByIdList"; $str = curlPost($api, $header, array("format" => "json", "idList" => json_encode($groupIds))); foreach ($str["groupList"] as $value1) { $conn->insert(array("id" => $value1["id"], "title" => $value1["name"], "jhid" => $value["id"], "jhtitle" => $value["title"]), "tianyunzi.360_group"); echo "插入了计划[" . $value["title"] . "],分组[" . $value1["name"] . "]\n"; } }
<?php // CREATING A MATCH require "init.php"; $matchid = $_POST['matchid']; $isWaiting = true; $name = $_POST['name']; $matchDtl = array('id' => $matchid); // $match=curlPost($matchDtl,'http://*****:*****@162.209.21.251/engage_cms/engage/api/quizsql/findMatchId/'); $match = curlPost($matchDtl, $basePath . '/findMatchId/'); $q_match = json_decode($match, TRUE); if ($q_match) { // $rmatch = $q_match; $isWaiting = $q_match['match_player_b'] != '' ? false : true; } if ($isWaiting === false) { /*foreach($query_match as $q_match): $match_id=$q_match->match_id; $match_status=$q_match->match_status; $match_player_a_isactive=$q_match->match_player_a_isactive; $match_player_b_isactive=$q_match->match_player_b_isactive; endforeach;*/ $match_result_details['id'] = $q_match['match_id']; $match_result_details['status'] = $q_match['match_status']; $match_result_details['isactive'] = array('a' => $q_match['match_player_a_isactive'], 'b' => $q_match['match_player_b_isactive']); //$result['rematch']="true"; $result = array(); $result['match'] = $match_result_details; $arr = array('matchid' => $matchid, 'match' => $result, 'isWaiting' => $isWaiting); } else { $arr = array('matchid' => $matchid, 'isWaiting' => $isWaiting);
/** * 功能:忘记密码 */ public function forgetpass() { $login_user = I('post.login_user'); $code = getRandomNum(6); //if($row) //{ $map['login_user'] = $login_user; $data['forgetcode'] = $code; M('Member')->where($map)->save($data); //} $_account = 'cf_zcsd'; $_password = '******'; $_url = 'http://106.ihuyi.cn/webservice/sms.php?method=Submit&format=json'; $data = array('account' => $_account, 'password' => $_password, 'mobile' => $login_user, 'content' => '亲爱的客户大大,您的账户正在进行密码重置,这是给您的验证码【' . $code . '】,请勿向任何人提供您收到的短信校验码'); $res_json = curlPost($_url, $data, 5); $res = json_decode($res_json, 1); if ($res['code'] == 2) { $this->json_ok(true); } $this->json_error($res['msg']); }
function ui_render($channel, $data) { // runelog('ui_render channel: '.$channel.', data: ',$data); curlPost('http://127.0.0.1/pub?id=' . $channel, $data); }
// Search radio station if ($_POST['querytype'] === 'search' && isset($_POST['args'])) { echo curlGet($dirblecfg['baseurl'] . 'search/apikey/' . $dirblecfg['apikey'] . '/search/' . $_POST['args'], $proxy); } // Get stations by continent if ($_POST['querytype'] === 'continent' && isset($_POST['args'])) { echo curlGet($dirblecfg['baseurl'] . 'continent/apikey' . $dirblecfg['apikey'] . '/continent/' . $_POST['args'], $proxy); } // Get stations by country if ($_POST['querytype'] === 'country' && isset($_POST['args'])) { echo curlGet($dirblecfg['baseurl'] . 'country/apikey' . $dirblecfg['apikey'] . '/country/' . $_POST['args'], $proxy); } // Add station if ($_POST['querytype'] === 'addstation' && isset($_POST['args'])) { // input array $_POST['args'] = array('name' => 'value', 'streamurl' => 'value', 'website' => 'value', 'country' => 'value', 'directory' => 'value') echo curlPost($dirblecfg['baseurl'] . 'station/apikey/' . $dirblecfg['apikey'], $_POST['args'], $proxy); } } } break; case 'jamendo': if ($activePlayer === 'MPD') { $apikey = $redis->hGet('jamendo', 'clientid'); $proxy = $redis->hGetall('proxy'); if ($_POST['querytype'] === 'radio') { $jam_channels = json_decode(curlGet('http://api.jamendo.com/v3.0/radios/?client_id=' . $apikey . '&format=json&limit=200', $proxy)); foreach ($jam_channels->results as $station) { $channel = json_decode(curlGet('http://api.jamendo.com/v3.0/radios/stream?client_id=' . $apikey . '&format=json&name=' . $station->name, $proxy)); $station->stream = $channel->results[0]->stream; } // TODO: add cache jamendo channels on Redis
<?php // FINDING MATCH require "init.php"; $matchid = 0; $isWaiting = true; $name = $_GET['name']; $frRes = json_decode(file_get_contents('http://*****:*****@162.209.21.251/engage_cms/engage/api/quizsql/findMatch/find/match/format/json'), TRUE); if ($frRes != 0) { $matchid = $frRes[0]['match_id']; $updateDtl = array('player' => $name, 'id' => $matchid); $updateUrl = 'http://*****:*****@162.209.21.251/engage_cms/engage/api/quizsql/joinMatch/'; $updateDb = curlPost($updateDtl, $updateUrl); $isWaiting = $updateDb == true ? false : ""; } else { $createDtl = array('player' => $name); $createUrl = 'http://*****:*****@162.209.21.251/engage_cms/engage/api/quizsql/createMatch/'; $createDb = curlPost($createDtl, $createUrl); $matchid = $createDb; } $arr = array('matchid' => $matchid, 'isWaiting' => $isWaiting); echo json_encode($arr);
function sendSMS($to, $msg) { global $config; $tolist = $to['sms']; $param = array(); $param['user'] = $config['sms']['user']; $param['passwd'] = $config['sms']['passwd']; $param['phone'] = $tolist; $param['msg'] = str_replace("\n", "%0a", $msg); $param = http_build_query($param); $data = curlPost($config['sms']['api'], $param); $data = str_replace("'", "\"", $data); $status = json_decode($data, true); if ($status['data']['result'] == "OK") { return "succ"; } else { alarmLog($msg, $data); return "failed"; } }
<?php // CREATING A MATCH require "init.php"; $matchid = 0; $isWaiting = true; $name = $_GET['name']; $data = array('player' => $name); $url = 'http://*****:*****@162.209.21.251/engage_cms/engage/api/quizsql/createMatch/'; $result = curlPost($data, $url); $matchid = $result > 0 ? $result : 0; $arr = array('matchid' => $matchid, 'isWaiting' => $isWaiting); echo json_encode($arr);
/** * 向平台发送请求 */ private function sendSms($data) { $xml = curlPost($this->baseurl, $data); return $this->readXML($xml); }
$header = array(); $header[] = "serveToken:" . microtime(1); $header[] = "apiKey:1kg8tunzfxt8zvzpf53vjr5es45lvszh"; $str = curlPost($api, $header, $postData); if (!isset($str["accessToken"])) { exit("用户登录验证失败!\n"); } else { echo "用户登录验证成功!\n"; } /*查询下所有的推广计划 */ $api = "https://api.e.360.cn/2.0/account/getCampaignIdList"; $header[] = "accessToken:" . $str["accessToken"]; $header[] = "sessionToken:" . $str["sessionToken"]; $params = array("format" => "json"); $str = curlPost($api, $header, $params); if (!isset($str["campaignIdList"])) { exit("无法获取到任何推广计划id\n"); } else { echo "所有推广计划获取成功!\n"; } $campaignIdList = $str["campaignIdList"]; /* 根据推广信息id查询推广计划的具体内容*/ $campaignArr = array(); $api = "https://api.e.360.cn/2.0/campaign/getInfoByIdList"; $params = array("format" => "json", "idList" => json_encode($campaignIdList)); $str = curlPost($api, $header, $params); foreach ($str["campaignList"] as $value) { $conn->insert(array("id" => $value["id"], "title" => $value["name"]), "tianyunzi.360_jihua"); echo "计划[" . $value["name"] . "]插入\n"; continue; }
// CREATING A MATCH require "init.php"; $matchid = $_POST['matchid']; /* $sql = "SELECT * FROM engage_match WHERE match_id=$matchid"; $res = mysqli_query($conn, $sql); if(mysqli_num_rows($res) != 0){ $get = mysqli_fetch_array($res); } mysqli_close($conn); */ $findMatchDtl = array('id' => $matchid); // $findMatchUrl='http://*****:*****@162.209.21.251/engage_cms/engage/api/quizsql/findMatchId/'; $findMatchUrl = $basePath . '/findMatchId/'; $findMatchDb = curlPost($findMatchDtl, $findMatchUrl); $get = json_decode($findMatchDb, TRUE); $playera = $get['match_player_a']; $playeraa = $get['match_player_a_isactive']; $playera_un = $get['match_player_username_a']; $playeraicon = $get['player_a_photo']; $playerabadge = $get['player_a_badge']; // $playerabadge = 'Handa'; $playerb = $get['match_player_b']; $playerab = $get['match_player_b_isactive']; $playerb_un = $get['match_player_username_b']; $playerbicon = $get['player_b_photo']; $playerbbadge = $get['player_b_badge']; // $playerbbadge = 'Handa'; $players['a'] = array('username' => $playera_un, 'name' => $playera, 'icon' => $playeraicon, 'badge' => $playerabadge, 'place' => 'a', 'score' => 0, 'isactive' => $playeraa); $players['b'] = array('username' => $playerb_un, 'name' => $playerb, 'icon' => $playerbicon, 'badge' => $playerbbadge, 'place' => 'b', 'score' => 0, 'isactive' => $playerab);