function ip_wpcf7_mail_sent($wpcf7){ $submission = WPCF7_Submission::get_instance(); if ( $submission ) { $formdata = $submission->get_posted_data(); $email = $formdata['your-email']; $first_name = $formdata['your-first-name']; $last_name = $formdata['your-last-name']; $tel = $formdata['your-tel']; $plan = $formdata['your-plan']; } $time = $today = date("F j, Y, g:i a"); // Open Agent: $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://ag.panda8.co/api?action=createAgentPph&creditAgent=1000&credit=100¤cy=USD&masterId=DEMVI&numOfUser=1&email='.$email.'&key=BBBAB3NzaC1yc2EAAAABJQAAAIEAhCdDMhGHdaw1uj9MH2xCB4jktwIgm4Al7S8rxvovMJBAuFKkMDd0vW5gpurUAB0PEPkxh6QFoBNazvio7Q03f90tSP9qpJMGwZid9hJEElplW8p43D3DdxXykLays2M8V2viYGLbiXvAbOECzwD4IaviOpylX0PaFznSR4ssXd0Int', CURLOPT_USERAGENT => 'PPH186', CURLOPT_FOLLOWLOCATION => 1, )); $resp = curl_exec($curl); $variables = json_decode($resp,true); $agent = strtoupper($variables['agentId']); $password = $variables['password']; curl_close($curl); // Send Info to bot $text = urlencode("-- Sign up -- \n".$time."\n"."First Name: ".$first_name."\n"."Last Name: ".$last_name."\n"."Email: ".$email."\n"."Tel: ".$tel."\n"."Plan: ".$plan."\nAgent ID: ".$agent); $curl = curl_init(); // Set some options - we are passing in a useragent too here curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://pph186.com/bot.php?key=b6fbc59dea1f5c41551f895886edbee5&msg='.$text.'&agent_id=sa', CURLOPT_USERAGENT => 'PPH186' )); // Send the request & save response to $resp $resp = curl_exec($curl); // Close request to clear up some resources curl_close($curl); $params = array( "first_name" => $first_name, "last_name" => $last_name, "phone_mobile" => $tel, "email1" => $email, "account_name" => $agent, "account_description" => $plan, "campaign_id" => "c78e72d1-bfaa-b060-be8e-56cb258c33e6", "assigned_user_id" => "1", ); echo httpPost("http://crm.pph186.com/index.php?entryPoint=WebToLeadCapture",$params); $_SESSION["first_name"] = $first_name; $_SESSION["last_name"] = $last_name; $_SESSION["account_name"] = $agent; }
function getPushResult($url, $appKey, $masterSecret, $taskId) { $params = array(); $params["action"] = "getPushMsgResult"; $params["appkey"] = $appKey; $params["taskId"] = $taskId; $sign = createSign($params, $masterSecret); $params["sign"] = $sign; $data = json_encode($params); $result = httpPost($url, $data); return $result; }
/** * 下载图像 */ public function downloadHeadImg() { ignore_user_abort(true); set_time_limit(0); for ($i = 100; $i > 0; $i++) { $rt = $this->table('task_headimgdownload')->where(array('status' => 0))->get(); if (!$rt) { $this->setTimeOut($i); continue; } $tempPath = '../TempImg/'; $path = 'img/headImg/'; foreach ($rt as $a) { //先验证是否已更换图片 $user = $this->table('user')->where(array('id' => $a['user_id']))->get(array('photo'), true); if ($user['photo'] != $a['photo']) { $status = 3; } else { $img = httpGet($a['photo']); $fileName = time() . rand(10000, 99999) . '.jpg'; $save = file_put_contents($tempPath . $fileName, $img); if ($save) { $uploadStatus = true; $image = new \System\lib\Image\Image($tempPath . $fileName); $fileName2 = str_replace('.jpg', '_150.jpg', $fileName); $image->thumb(200, 10000)->save($tempPath . $fileName2); $status = 1; //上传到图片服务器 $upload = httpPost($this->config('IMG_UPLOAD'), ['file' => new \CURLFile(realpath($tempPath . $fileName)), 'savePath' => $path, 'saveName' => basename($tempPath . $fileName)], true); $upload = json_decode($upload, true); if (!($upload && $upload['result'] == true)) { $uploadStatus = false; } //上传压缩图 $upload2 = httpPost($this->config('IMG_UPLOAD'), ['file' => new \CURLFile(realpath($tempPath . $fileName2)), 'savePath' => $path, 'saveName' => basename($tempPath . $fileName2)], true); $upload2 = json_decode($upload, true); if (!($upload2 && $upload2['result'] == true)) { $uploadStatus = false; } if ($uploadStatus == false) { $status = 2; } else { $up2 = $this->table('user')->where(['id' => $a['user_id']])->update(['photo' => '/', $path . $fileName, 'photo_150' => '/', $path . $fileName2]); $status = 1; } } else { $status = 2; } } $up = $this->table('task_headimgdownload')->where(['id' => $a['id']])->update(array('status' => $status, 'execute_time' => time())); } } }
private function _getTicket() { /** * ticket要进行缓存 */ //获取ticket,由action_name来决定是临时的还是永久的 $ticket_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={$this->access_token}"; $scene = array($this->_sceneKey() => $this->scene_param); $param = array("action_name" => $this->action_name, "action_info" => array("scene" => $scene)); if ($this->action_type == 1) { $param['expire_seconds'] = 604800; } $ticket_return = httpPost($ticket_url, json_encode($param)); return $ticket_return; }
function runAll() { global $servers; file_put_contents('var/locales', json_encode(array_keys($servers))); foreach ($servers as $locale => $server) { $account = 'royalAdmin'; $pass = '******'; if (!empty($server['account'])) { $account = $server['account']; $pass = $server['pass']; } httpPost($server['login_url'], array('account' => $account, 'password' => $pass, 'submit' => true)); $dashboard = httpGet($server['dashboard_url'], array()); preg_match('/var statisDatas = ([^;]*);/sim', $dashboard, $data); $dataArray = json_decode($data[1], true); handleData($locale, $dataArray); } }
public static function registerAchievements() { global $achievements, $appID, $appName, $appURL; $appToken = findAppToken(); $results = array(); // Read the graph to find out what's already associated with the app $current = json_decode(file_get_contents("https://graph.facebook.com/{$appID}/achievements&access_token={$appToken}"), true); $current = $current['data']; $registered = array(); foreach ($current as $a) { $registered[] = $a['url']; } foreach ($achievements as $name => $details) { $achURL = "http:{$appURL}?" . "f=ra&n={$name}"; if (in_array($achURL, $registered)) { continue; } $order = $details['display_order']; // Write to the graph if any achievements have been added or changed $results[$achURL] = httpPost("https://graph.facebook.com/{$appID}/achievements", array('access_token' => $appToken, 'achievement' => $achURL, 'display_order' => $order)); } return array('had' => array_fill_keys($registered, true), 'added' => $results); }
/** * HTTP[s] POST request * * @author Robin Gareus <*****@*****.**> * @param $host: hostname ; eg 'example.org' * @param $path: request' eg '/index.php?id=123' * @param $data_to_send : data to POST after the HTTP header. * @param $opts various transport layer options (ssl, port, cert,..) * @param $auth optional username, password and type ('basic', 'nodigest') * @param $head custom http header * * if $opts is an empty array() a standard HTTP to port 80 request is performed. * * set auth['type']='basic' to use plain-text auth, * digest-auth will be handled automatically if $auth['username'] is set and a 401 * status is encountered. - use auth['type']='nodigest' to override. * */ function httpPost($host, $path, $data_to_send, $opts = array('cert' => "", 'transport' => 'ssl://', 'port' => 443, 'headers' => 0), $auth = array('username' => "", 'password' => "", 'type' => ""), $head = array('Content-type' => 'text/xml')) { $transport = ''; $port = 80; if (!empty($opts['transport'])) { $transport = $opts['transport']; } if (!empty($opts['port'])) { $port = $opts['port']; } $remote = $transport . $host . ':' . $port; $context = stream_context_create(); $result = stream_context_set_option($context, 'ssl', 'verify_host', true); if (!empty($opts['cert'])) { $result = stream_context_set_option($context, 'ssl', 'cafile', $opts['cert']); $result = stream_context_set_option($context, 'ssl', 'verify_peer', true); } else { $result = stream_context_set_option($context, 'ssl', 'allow_self_signed', true); } $fp = stream_socket_client($remote, $err, $errstr, 60, STREAM_CLIENT_CONNECT, $context); if (!$fp) { trigger_error('httpPost error: ' . $errstr); return NULL; } $req = ''; $req .= "POST {$path} HTTP/1.1\r\n"; $req .= "Host: {$host}\r\n"; if ($auth['type'] == 'basic' && !empty($auth['username'])) { $req .= "Authorization: Basic "; $req .= base64_encode($auth['username'] . ':' . $auth['password']) . "\r\n"; } elseif ($auth['type'] == 'digest' && !empty($auth['username'])) { $req .= 'Authorization: Digest '; foreach ($auth as $k => $v) { if (empty($k) || empty($v)) { continue; } if ($k == 'password') { continue; } $req .= $k . '="' . $v . '", '; } $req .= "\r\n"; } foreach ($head as $k => $v) { $req .= $k . ': ' . $v . "\r\n"; } if (empty($head['Content-type'])) { $ct = 'text/xml'; $req .= "Content-type: {$ct}\r\n"; } $req .= 'Content-length: ' . strlen($data_to_send) . "\r\n"; $req .= "Connection: close\r\n\r\n"; fputs($fp, $req); fputs($fp, $data_to_send); while (!feof($fp)) { $res .= fgets($fp, 128); } fclose($fp); if ($auth['type'] != 'nodigest' && !empty($auth['username']) && $auth['type'] != 'digest' && preg_match("/^HTTP\\/[0-9\\.]* 401 /", $res)) { if (1 == preg_match("/WWW-Authenticate: Digest ([^\n\r]*)\r\n/Us", $res, $matches)) { foreach (split(",", $matches[1]) as $i) { $ii = split("=", trim($i), 2); if (!empty($ii[1]) && !empty($ii[0])) { $auth[$ii[0]] = preg_replace("/^\"/", '', preg_replace("/\"\$/", '', $ii[1])); } } $auth['type'] = 'digest'; $auth['uri'] = 'https://' . $host . $path; $auth['cnonce'] = $this->_randomNonce(); $auth['nc'] = 1; $a1 = md5($auth['username'] . ':' . $auth['realm'] . ':' . $auth['password']); $a2 = md5('POST' . ':' . $auth['uri']); $auth['response'] = md5($a1 . ':' . $auth['nonce'] . ':' . $auth['nc'] . ':' . $auth['cnonce'] . ':' . $auth['qop'] . ':' . $a2); return httpPost($host, $path, $data_to_send, $opts, $auth, $head); } } # end if DIGEST AUTH if (1 != preg_match("/^HTTP\\/[0-9\\.]* ([0-9]{3}) ([^\r\n]*)/", $res, $matches)) { trigger_error('httpPost: invalid HTTP reply.'); return NULL; } if (1 != preg_match("/^2[0-9]{2}\$/", $matches[1])) { trigger_error('httpPost: HTTP error: ' . $matches[1] . ' ' . $matches[2]); return NULL; } if (!$opts['headers']) { $res = preg_replace("/^.*\r\n\r\n/Us", '', $res); } return $res; }
function loadTaskDefinition($task) { $task = preg_replace('[^a-z0-9-]', '', $task); $task = str_replace('-', '_', $task); $fn = 'task_' . $task; if (!function_exists($fn)) { $taskSource = httpPost(DISPATCHER_URL, array('action' => 'tasksource', 'task' => $task)); if ($taskSource && $taskSource != '404') { $taskSource = preg_replace('/^(<\\?(php)?)?(.*)(\\?>)?$/m', '$3', $taskSource); echo "TaskSource: {$taskSource}\n"; // Checks for syntax errors if (@eval('return true; ' . $taskSource)) { //eval($taskSource); if (function_exists($fn)) { return $fn; } echo "ERR: Missing function definition for {$fn}\n"; return false; } echo "ERR: Synatx error for task '{$task}'\n"; } return false; } return $fn; }
<?php /** * Test Send message * * @author zendzhang<*****@*****.**> * @version $Id$ */ $data = array('queuename' => 'Demo', 'queuedata' => 'act=add&id=100'); $result = json_decode(httpPost('localhost', '/SendMessage.php', $data), true); if (false === $result) { echo "Request failure!\n"; } else { if (isset($result['status']) && $result['status'] == 1) { echo "Send message successful!\n"; } else { echo "Send message failure,error:{$result['data']}\n"; } } ///////////////////////////////////////////////////////////////////// /** * HTTP post request * * @param string $host * @param string $url * @param sting $data * @param int $port * @param init $timeout * @return mixed */ function httpPost($host, $url, $data, $port = 80, $timeout = 10)
<?php require 'config.php'; $dados = array('categoria' => 'Entretenimento'); $url = 'http://127.0.0.1/webservices/api-blog/json/categoria-cadastrar.php'; $r = httpPost($dados, $url); $dados = json_decode($r, true); print_r($dados);
public function get_rate() { header('Content-Type: application/xml'); $origin = $this->input->post('origin'); $destination = $this->input->post('destination'); //get the items $items = json_decode($_REQUEST["items"]); $item = ''; for ($i = 0; $i < count($items); $i++) { $sq = $i + 1; $item .= '<Item sequence="' . $sq . '" freightClass="' . $items[$i]->class . '">'; $item .= '<Weight units="' . $items[$i]->weight_unit . '">' . $items[$i]->weight . '</Weight>'; $item .= '<Quantity units="' . $items[$i]->quantity_unit . '">' . $items[$i]->quantity . '</Quantity>'; $item .= '</Item>'; } //if ($request["origin"] == "" || $request["destination"] == "" || $request["pieces"] == "" || $request["weight"] == "" || $request["commodity"] == "" || $request["height"] == "" || $request["width"] == "" || $request["lenght"] == "") { // $request["origin"] = "60606"; // $request["destination"] = "33133"; // $request["pieces"] = "1"; // $request["weight"] = "400"; // $request["commodity"] = "100"; // $request["lenght"] = "20"; // $request["width"] = "400"; // $request["height"] = "20"; // //} function httpPost($url, $params) { $postData = ''; //create name value pairs seperated by & foreach ($params as $k => $v) { $postData .= $k . '=' . $v . '&'; } rtrim($postData, '&'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, count($postData)); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); $output = curl_exec($ch); curl_close($ch); return $output; } $peticion = '<service-request> <!-- Consult the WSDocumentation .doc file section 2.1.1 for more details on these values. --> <service-id>XMLRating</service-id> <!-- Supply a unique request-id to improve traceability & diagnostics --> <request-id>20150302-MG-Test-ABC</request-id> <data> <RateRequest> <ReturnAssociatedCarrierPricesheet>true</ReturnAssociatedCarrierPricesheet> <!-- RatingLevel: Specify the company level at which the rating will perform. The company is either defined by name or account number. --> <!-- Enterprise Customer Acct Number: --> <RatingLevel isCompanyAccountNumber="true"/> <Constraints> <!-- <Carrier name="" scac=""/> is optional; either name or scac attribute must be set (not both) value if specified --> <Mode/> <ServiceFlags/> <Equipments/> <!-- All constraints are optional; <ServiceFlags> <ServiceFlag code=""/> </ServiceFlags> <Equipments> <Equipment code=""/> </Equipments> --> <!-- <Contract type="" name=""/> is optional; Type must have value if specified --> <!-- All constraints are optional; <ContractService/> <PaymentTerms/> --> </Constraints> <Items> ' . $item . ' </Items> <Events> <Event sequence="1" type="Pickup" date="12/15/2015 16:20"> <Location> <Zip>' . $origin . '</Zip> <Country>USA</Country> </Location> </Event> <Event sequence="2" type="Drop" date="12/19/2015 16:22"> <Location> <Zip>' . $destination . '</Zip> <Country>USA</Country> </Location> </Event> </Events> <!-- <LinearFeet/> is optional; must have value if specified --> <!-- <RatingCount/> is optional; must have value if specified --> <ReferenceNumbers> <ReferenceNumber type=""/> </ReferenceNumbers> <!-- <MaxPriceSheets/> is optional; must have value if specified --> <ShowInsurance>false</ShowInsurance> </RateRequest> </data> </service-request>'; $params = array("userid" => "webuser", "password" => "us3rw3b", "request" => urlencode($peticion)); $xml = httpPost("https://cargotsi.mercurygate.net/MercuryGate/common/remoteService.jsp", $params); //echo $peticion; //print $xml; $response = simplexml_load_string($xml); print base64_decode($response->data); }
<?php include 'include.php'; if (!isset($_GET['id'])) { setFlash("action impossible.", "danger"); redirect("accueil.php"); die; } $user = $_SESSION['profil']['id']; $post = $_GET['id']; $fields = ['content' => $_POST['content'], 'user_id' => urlencode($user), 'post_id' => urlencode($post)]; $url = 'http://api-rest-youcef-m.c9.io/comment/new'; $result = httpPost($fields, $url); $result; if ($result['code'] == 400) { setFlash("action impossible.", "danger"); redirect('afficherphoto.php?id=' . $post); } elseif ($result['code'] == 200) { $user = json_decode($result['content']); foreach ($user as $k => $v) { $_SESSION['profil'][$k] = $v; } setFlash('Votre commentaire a bien été envoyé'); redirect('afficherphoto.php?id=' . $post); } else { setFlash('Nos services sont en panne, nous faisons notre possible pour régler le problème.', 'danger'); redirect('index.php'); }
} if ($inheader == 0) { echo $resp_str; } } echo $resp_str; echo "\r\n"; if ($nMaxReturn == 0) { $_SESSION["session_id"] = substr($resp_str, strpos($resp_str, "Set-Cookie: ") + 12, 45); //echo $_SESSION["session_id"]; if (substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10) == 0) { $_SESSION["activeid"] = substr($resp_str, strpos($resp_str, "<ActiveID>") + 10, strpos($resp_str, "</ActiveID>") - strpos($resp_str, "<ActiveID>") - 10); } } else { if (substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10) == 0) { echo "\r\n"; echo "操作成功"; } else { echo "\r\n"; echo substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10); //处理返回值. $_SESSION["ReturnString"] = substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10); } } fclose($fp); } httpPost("/LANZGateway/Login.asp", "UserID=968888&Account=12244kk&Password=321321", "", 0); httpPost("/LANZGateway/SendSMS.asp", "SMSType=1&Phone=13600000&Content=PHP\r\n接口测试demo调试&ActiveID=" . $_SESSION["activeid"], $_SESSION["session_id"], 1); httpPost("/LANZGateway/Logoff.asp", "ActiveID=" . $_SESSION["activeid"], $_SESSION["session_id"], 2); ?>
curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //execute post $result = curl_exec($ch); #print_r($result); curl_close($ch); return $result; } $input = '10 8'; $code = $_REQUEST['code']; //print $url = 'http://api.hackerrank.com/checker/submission.json'; $key = 'hackerrank|631865-613|616ab1ad542ca4dbeabd7f04e266006c5c5a14f3'; $query = array(); $query['source'] = urlencode($code); $query['testcases'] = urlencode(json_encode(array($input))); $query['lang'] = 5; $query['api_key'] = urlencode($key); $q = array(); $fields_string = ""; foreach ($query as $key => $value) { $fields_string .= $key . '=' . $value . '&'; } rtrim($fields_string, '&'); $result = ""; $result = httpPost($url, $q, $fields_string); //print_r($result); $result = json_decode($result, true); //print_r($result['result']['stdout']); echo $result['result']['stdout'][0];
case 2: //HTTP echo "Sent HTTP\r\n"; $data = array(); $data["to_address"] = $address; $data["amount"] = $value; $data["btc_amount"] = $btc; $data["confirmations"] = $confirmations; $data["txhash"] = $txhash; $data["block"] = -1; $data["signature"] = sha1( $address . $value . $confirmations . $txhash . $currentheight . $user->secret ); if(filter_var($user->url, FILTER_VALIDATE_URL) !== FALSE && $user->url != "") { $result = httpPost($user->url, $data); if ($result === FALSE) $success = false; else $success = true; } else { mail(SYS_ADMIN, "URL in monitor bad", "Skipping http attempt for ".$user->url, "FROM: monitor@bitping.net"); } break; case 3: //Pubnub $data = array(); $data["to_address"] = $address; $data["amount"] = $value;
/** * 获取微信media并保存 * @param str $mediaID media_id * @param str $path 目录 * @return bool */ public static function getWechatMedia($mediaID, $savePath = null) { if (empty($savePath)) { $savePath = 'order/' . time() . '_' . rand(1000, 9999) . ".jpg"; } $weObj = new \System\lib\Wechat\Wechat(\System\Entrance::config("WEIXIN_CONFIG")); $media = $weObj->getMedia($mediaID); if (!$media) { return false; } $temPath = '../TempImg/'; //临时保存路径 if (!dirExists($temPath)) { return false; } $fileName = basename($savePath); /* $fileName=basename($savePath); $checkPath=str_replace($fileName, '', $savePath); if(!dirExists($checkPath)) return false; */ if (!file_put_contents($temPath . $fileName, $media)) { return false; } //生成压缩图片 $image = new \System\lib\Image\Image($temPath . $fileName); $img1 = $image->size(); $return['img1']['path'] = $temPath . $fileName; $return['img1']['width'] = $img1[0]; $return['img1']['heigh'] = $img1[1]; //200*200缩略图 $img2Path = $temPath . str_replace('.', '_thumb200.', $fileName); $image->thumb(200, 10000)->save($img2Path); $img2 = $image->size(); $return['img2']['path'] = $img2Path; $return['img2']['width'] = $img2[0]; $return['img2']['heigh'] = $img2[1]; //360*360缩略图 $img3Path = $temPath . str_replace('.', '_thumb360.', $fileName); $image->open($temPath . $fileName); $image->thumb(360, 10000)->save($img3Path); $img3 = $image->size(); $return['img3']['path'] = $img3Path; $return['img3']['width'] = $img3[0]; $return['img3']['heigh'] = $img3[1]; //dump($return); //上传 foreach ($return as $key => $a) { $upload = httpPost(\System\Entrance::config('IMG_UPLOAD'), ['file' => new \CURLFile(realpath($a['path'])), 'savePath' => dirname($savePath) . '/', 'saveName' => basename($a['path'])], true); //dump($upload); $upload = json_decode($upload, true); if (!($upload && $upload['result'] == true)) { return false; } unlink($a['path']); $return[$key]['path'] = $upload['path']; } return $return; }
if ($inheader && ($resp_str == "\n" || $resp_str == "\r\n")) { $inheader = 0; } if ($inheader == 0) { echo $resp_str; } } echo $resp_str; echo "\r\n"; if ($nMaxReturn == 0) { $_SESSION["session_id"] = substr($resp_str, strpos($resp_str, "Set-Cookie: ") + 12, 45); //echo $_SESSION["session_id"]; if (substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10) == 0) { $_SESSION["activeid"] = substr($resp_str, strpos($resp_str, "<ActiveID>") + 10, strpos($resp_str, "</ActiveID>") - strpos($resp_str, "<ActiveID>") - 10); } } else { if (substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10) == 0) { echo "\r\n"; echo "操作成功"; } else { echo "\r\n"; echo substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10); //处理返回值. $_SESSION["ReturnString"] = substr($resp_str, strpos($resp_str, "<ErrorNum>") + 10, strpos($resp_str, "</ErrorNum>") - strpos($resp_str, "<ErrorNum>") - 10); } } fclose($fp); } httpPost("/LANZGateway/DirectSendSMSs.asp", "UserID=1234569&Account=123456&Password=56EAF4A2C651BFF3D77236A4E3FE16E44C48EA39&SMSType=1&Phones=1111111111&Content=gfdsa&SendDate=&Sendtime=", "", 1); ?>
public function paypal_notify() { // $data="mc_gross=25.00&invoice=18&protection_eligibility=Eligible&address_status=confirmed&payer_id=SXZZVBRD9D4JJ&tax=0.00&address_street=1+Main+St&payment_date=05%3A23%3A07+Mar+01%2C+2015+PST&payment_status=Completed&charset=windows-1252&address_zip=95131&first_name=test&mc_fee=1.03&address_country_code=US&address_name=test+buyer¬ify_version=3.8&custom=&payer_status=verified&business=sunxguo-facilitator%40163.com&address_country=United+States&address_city=San+Jose&quantity=1&verify_sign=ACkCvEsJvmOecWFvZsZ4A2g5Nt9MApZMHtotk5..k3ZcBn3q0UA7WuLa&payer_email=sunxguo-buyer%40163.com&txn_id=1VL90883LX3271452&payment_type=instant&last_name=buyer&address_state=CA&receiver_email=sunxguo-facilitator%40163.com&payment_fee=1.03&receiver_id=XX2RXQZAHTW58&txn_type=web_accept&item_name=iphone6+plus+64G%26&mc_currency=USD&item_number=&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=iphone6+plus+64G%26&payment_gross=25.00&shipping=0.00&ipn_track_id=e5af3dcbf778"; $data = file_get_contents("php://input"); $notify = $this->convert_input_data($data); // 由于这个文件只有被Paypal的服务器访问,所以无需考虑做什么页面什么的, // 这个页面不是给人看的,是给机器看的 $order_id = (int) $notify['invoice']; $order = $this->dbHandler->selectPartData('order', 'id_order', $order_id); $order = $order[0]; $app = $this->dbHandler->selectPartData('app', 'id_app', $order->appid_order); $app = $app[0]; $merchant = $this->dbHandler->selectPartData('merchant', 'id_merchant', $app->merchant_id_app); $merchant = $merchant[0]; // 由于该URL不仅仅只有Paypal的服务器能访问,其他任何服务器都可以向该方法发起请求。 // 所以要判断请求发起的合法性,也就是要判断请求是否是paypal官方服务器发起的 // 拼凑 post 请求数据 $notify["cmd"] = "_notify-validate"; $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; $res = httpPost($url, $notify); if ($res && !empty($order)) { // 本次请求是否由Paypal官方的服务器发出的请求 if (strcmp($res, 'VERIFIED') == 0) { /** * 判断订单的状态 * 判断订单的收款人 * 判断订单金额 * 判断货币类型 */ if ($notify['payment_status'] != 'Completed' or $notify['receiver_email'] != $merchant->paypal_merchant or 'USD' != $notify['mc_currency']) { // 如果有任意一项成立,则终止执行。由于是给机器看的,所以不用考虑什么页面。直接输出即可 exit('fail'); } else { // 如果验证通过,则证明本次请求是合法的 $this->email($merchant->email_merchant, 'Success', "订单:" . $order->num_order . "支付成功"); $this->dbHandler->updatedata("order", array("state_order" => 1), "id_order", $order_id); exit('success'); } } else { exit('fail'); } } else { exit('No data'); } }
<?php function httpPost($url, $params) { $postData = http_build_query($params); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, count($postData)); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); $output = curl_exec($ch); curl_close($ch); return $output; } $docName = isset($_GET['doc_name']) ? $_GET['doc_name'] : 'xda'; $htmlContent = file_get_contents('mine.html'); $params = array('html_content' => $htmlContent, 'doc_name' => $docName); echo httpPost("http://localhost/toword_by_PhpWord/PHPWord-develop/samples/DocxApi.php", $params);
function twitchGetAccessToken($code) { $paramsTwitch = array('client_id' => TWITCH_CLIENT_ID, 'client_secret' => TWITCH_CLIENT_SECRET, 'grant_type' => "authorization_code", 'redirect_uri' => TWITCH_REDIRECT_URI, 'code' => $code); $loginResponse = httpPost("https://api.twitch.tv/kraken/oauth2/token", $paramsTwitch); return json_decode($loginResponse); }
function cfSetDomainARecord($domain, $recid, $ip, $name) { global $config_auth; $data = array('a' => "rec_edit", 'tkn' => $config_auth['tkn'], 'email' => $config_auth['email'], 'z' => $domain, 'type' => "A", 'id' => $recid, 'content' => $ip, 'ttl' => "600", 'name' => $name, 'service_mode' => "1"); return httpPost($data); }
public function pullNewsFromRemote() { $this->refreshToken(); $api = config("wechat_api.news.pull") . $this['access_token']; $post_data = array("type" => "news", "offset" => 0, "count" => 20); $result = httpPost($api, json_encode($post_data)); $news_list = json_decode($result[1], true); foreach ($news_list['item'] as $news) { $news_media_id = $news['media_id']; foreach ($news['content']['news_item'] as $k => $article) { $article['news_media_id'] = $news_media_id; $article['order'] = $k; $article['mp_id'] = $this['id']; //处理外链图片 $pattern = "/http:\\/\\/mmbiz.qpic.cn/"; $replacement = "https://mmbiz.qlogo.cn"; $article['thumb_url'] = preg_replace($pattern, $replacement, $article['thumb_url']); $article['content'] = preg_replace($pattern, $replacement, $article['content']); $t_article = Article::firstOrCreate(["news_media_id" => $news_media_id, "order" => $k]); foreach ($article as $k => $v) { $t_article[$k] = $v; } $t_article->save(); } } }
function moduletrad_ajax_handler() { $params = array('q' => urlencode(htmlspecialchars($_POST["q"])), 'key' => "bla", 'target' => $_POST["target"], 'source' => $_POST["source"]); function httpPost($url, $params) { $postData = ''; //crée les paires nom-valeur séparées par & foreach ($params as $k => $v) { $postData .= $k . '=' . $v . '&'; } $postData = rtrim($postData, '&'); //enlève le dernier & pour que la fin de l'url soit correcte $proxy = "172.20.12.74"; $proxyport = "3128"; $link = $url . '?' . $postData; //curl $ch = curl_init(); // initialise la session curl // réglage des options curl curl_setopt($ch, CURLOPT_URL, $link); // url à récupérer curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return la réponse du serveur /*curl_setopt($ch,CURLOPT_HEADER,false); // n'inclue pas l'en-tête dans la valeur de retour*/ curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_PROXYPORT, $proxyport); curl_setopt($cURL, CURLOPT_HTTPHEADER, array("Content-type: application/json", "Accept: application/json")); $output = curl_exec($ch); curl_close($ch); // ferme la session curl return trim($output); } $data = httpPost("http://galadriel.univ-lemans.fr:8002/translate", $params); $data = json_decode($data, true); $data = $data['data']['translations'][0]['translatedText']; wp_send_json($data); }
$postData = ''; //create name value pairs seperated by & foreach ($params as $k => $v) { $postData .= $k . '=' . $v . '&'; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_TIMEOUT, 20); $output = curl_exec($ch); curl_close($ch); return $output; } if (isset($_GET['sem']) and isset($_GET['sid'])) { if (is_numeric($_GET['sem']) and is_numeric($_GET['sid'])) { echo file_get_contents("https://www3.reg.cmu.ac.th/regist" . $_GET['sem'] . "/public/result.php?id=" . $_GET['sid']); } else { echo "ERROR"; } } elseif (isset($_GET['sem']) and isset($_GET['c']) and isset($_GET['lec']) and isset($_GET['lab'])) { if (is_numeric($_GET['sem']) and is_numeric($_GET['c']) and is_numeric($_GET['lec']) and is_numeric($_GET['lab'])) { $params = array("s_course1" => $_GET['c'], "s_lec1" => $_GET['lec'], "s_lab1" => $_GET['lab'], "op" => "bycourse"); echo httpPost("https://www3.reg.cmu.ac.th/regist" . $_GET['sem'] . "/public/search.php?act=search", $params); } else { echo "ERROR"; } }
<?php function httpPost($url, $data) { $curl = curl_init(); curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $data, CURLOPT_HEADER => 0, CURLOPT_TIMEOUT => 30)); $tmpInfo = curl_exec($curl); if (curl_errno($curl)) { echo 'Errno' . curl_error($curl); } curl_close($curl); return $tmpInfo; } //$alliance=$_GET['alliance']; $url = "http://mydgsd.com/api/menu/menuAPI.php"; $data = "act=getAllFoods&token=dhklfao3jsdlaj89cvsadas476"; $result = httpPost($url, $data); echo $result;
<?php $data = file_get_contents('php://input'); $application = getenv("VCAP_APPLICATION"); $application_json = json_decode($application, true); $applicationName = $application_json["name"]; if (substr($applicationName, -3) === "-ui") { // if suffixed with "-ui", remove trailing "-ui" $ordersAppName = substr($applicationName, 0, -3) . "-order-api"; } else { $ordersAppName = $applicationName . "-order-api"; } $applicationURI = $application_json["application_uris"][0]; $ordersHost = substr_replace($applicationURI, $ordersAppName, 0, strlen($applicationName)); $ordersRoute = "http://" . $ordersHost; $ordersURL = $ordersRoute . "/rest/orders"; function httpPost($data, $url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $output = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $code; } echo json_encode(array("httpCode" => httpPost($data, $ordersURL), "ordersURL" => $ordersURL));
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { header('Access-Control-Allow-Origin: *'); $fields = $_POST; function httpPost($file, $data) { $baseUrl = 'http://localhost.greatnonsens.com/form/' . $file; $curl = curl_init($baseUrl); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); curl_close($curl); return $response; } $t = httpPost($_POST['target'], $fields); echo $t; }
<?php // echo date('Ymd') . rand(); //echo rand(); echo time(); echo "<br>"; echo date('Ymd') . rand(); echo "<br>"; $signData = hash_hmac('sha1', "hello", '746D7SCHAIQ0QUZ0MRJWU0PQ3AD7PJ8B', false); $signData = strtoupper($signData); echo urlencode($signData); echo "<br>"; $Amount = '1111111111'; $OrderInfo = 'aaaaaaaa'; echo HashValue($Amount, $OrderInfo); function HashValue($Amount = NULL, $OrderInfo = NULL) { $string_value = $Amount . $OrderInfo; $HashValue = hash_hmac('sha1', $string_value, $secret_key, false); return $HashValue; } $params = array("name" => "Ravishanker Kusuma", "age" => "32", "location" => "India"); echo httpPost("http://hayageek.com/examples/php/curl-examples/post.php", $params);
public function addBulkInfo() { $table = ""; $data = json_decode($_POST['data']); $info = array(); switch ($data->infoType) { case "coupons": $table = "coupon"; $time = date("Y-m-d H:i:s"); $info = array("sid" => $data->sid, "facevalue" => $data->facevalue, "useprice" => $data->useprice, "beginvalid" => $data->beginvalid, "endvalid" => $data->endvalid, "addtime" => $time, "edittime" => $time); $users = array(); if ($data->buyerid == 0) { $allUsers = $this->getdata->getBuyers(array('result' => 'data')); foreach ($allUsers as $key => $value) { $users[] = $value->id; } } else { $usersLinecode = explode(',', $data->buyerid); foreach ($usersLinecode as $value) { $user = $this->getdata->getContentAdvance('buyer', array('linecode' => $value)); if (isset($user->id)) { $users[] = $user->id; } } } foreach ($users as $value) { $info['buyerid'] = $value; $this->dbHandler->insertData($table, $info); } if ($data->pushmsg == '1') { $pushUrl = 'http://182.92.156.106:9080/CDB/buyer/sendcoupons'; $ids = implode(',', $users); httpPost($pushUrl, array('ids' => $ids)); } break; } echo json_encode(array("result" => "success", "message" => "信息写入成功")); }
error_reporting(E_ALL); ini_set('display_errors', 1); $params = file_get_contents(Yii::app()->basePath . "/files/upload.json"); $datetime = $model->date; $content = $model->content; list($year, $month, $day) = explode("-", $datetime); $data = json_decode($params); $data->content = $content; $data->reviewer->name = $model->review_name; $data->publication->title = $model->publication_title; $data->complete_date->month = $month; $data->complete_date->year = $year; $newJsonString = json_encode($data); //echo $newJsonString; file_put_contents('./upload.json', $newJsonString); $url = httpPost("https://staging.publons.com/api/v2/review/", $newJsonString); //echo $url; //echo httpPosttest("http://hayageek.com"); $doi = file_get_contents("./doi.rtf"); list($a, $b, $c) = explode('.', (string) $doi); $temp1 = intval($c) + 1; $newdoi = $a . '.' . $b . '.' . $temp1; file_put_contents('./doi.rtf', $newdoi); $xml = simplexml_load_file('./template.xml'); //echo 'DOI: '.$doi; $xml->identifier = $doi; $xml->creators->creator->creatorName = $_GET["name"]; $xml->titles->title = $_GET["title"]; $xml->dates->date = $_GET["date"]; $xml->descriptions->description = $_GET["content"]; $xml->relatedIdentifiers->relatedIdentifier = $_GET["doi"];