function postDMs($xml, $sinceid = null) { global $DRE_USER, $DRE_ALLOW; if ($sinceid === null) { $sinceid = 0; } $dms = array(); foreach ($xml->direct_message as $dm) { if ($dm->id <= $sinceid) { continue; } $dms[round($dm->id)] = array('text' => (string) $dm->text, 'from' => (string) $dm->sender_screen_name); } ksort($dms, SORT_NUMERIC); foreach ($dms as $id => $val) { if (preg_match($DRE_ALLOW, $val['from'])) { $curl = getCURL(DRE_UPDURL); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, 'status=' . rawurlencode($val['text']) . '&' . 'source=dretweet'); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:')); $ret = curl_exec($curl); handleFailure($curl, $ret, 'while posting: ' . $val['text']); echo 'Posted: ' . $val['text'] . "\n"; } file_put_contents($DRE_USER . '.lastid', $id); } }
public function getWechatServerIp() { $access_token = $this->getAccessToken(); $url = "https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=" . $access_token; $result = getCURL($url); $data = json_decode($result, true); return $data; }
public function getTemporarySource() { $access_token = $this->getAccessToken(); $mediaid = ""; $url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=" . $access_token . "&media_id=" . $mediaid; $result = getCURL($url); Log::write("获取临时资源返回信息" . $result); }
$rootURL = 'http://m.kugou.com/'; function getCURL($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_TIMEOUT, 60); //超时时间 curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 302 redirect //curl_setopt($curl, CURLOPT_HEADER, 1); //curl_setopt($curl, CURLOPT_COOKIE, 'UOR=,open.weibo.com,; SINAGLOBAL=4278528405074.1177.1309500424912; ULV=1309741183318:2:2:1:521572103679.4796.1309741183316:1309500424938; wvr=3; un=test2reg@sina.cn; ALF=1310106051; USRHAJAWB=usrmdins19118; SUE=es%3D71b3f81d79260ac6ee2b9812e3e6613e%26es2%3Dbed6780afb8299fdf0b737e23bf4f505%26ev%3Dv1; SUP=cv%3D1%26bt%3D1309741164%26et%3D1309827564%26uid%3D2193710865%26user%3Dtest2reg.cn%26ag%3D8%26email%3Dtest2reg%2540sina.cn%26nick%3Dtest2reg%26name%3Dtest2reg%2540sina.cn%26sex%3D%26dob%3D%26ps%3D0; SSOLoginState=1309741164; WNP=2193710865%2C123; _s_tentry=login.sina.com.cn; Apache=521572103679.4796.1309741183316'); //cookie curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11'); //useragent curl_setopt($curl, CURLOPT_REFERER, 'http://m.kugou.com'); //refer //curl_setopt($curl, CURLOPT_COOKIEJAR,dirname(__FILE__)."/cookie.txt");//链接完成后保存cookie的文件 //curl_setopt($curl, CURLOPT_COOKIEFILE,"cookie.txt");//cookie文件 $data = curl_exec($curl); curl_close($curl); if ($data) { return $data; } else { return false; } } extract($_GET); if (isset($base) && !empty($base) && isset($query) && !empty($query)) { echo getCURL($rootURL . $base . '?' . urldecode($query)); }
$view_member = new Member($_GET['id']); if ($view_member->memExist) { // retrieve recommended quizzes $query_latest = sprintf("SELECT quiz_id, quiz_name, quiz_description, quiz_picture, fk_quiz_cat, member_name, fk_member_id, cat_name, likes, dislikes FROM q_quizzes, q_quiz_cat, s_members WHERE member_id = fk_member_id AND cat_id = fk_quiz_cat AND isPublished = 1 AND fk_member_id = %s ORDER BY creation_date DESC LIMIT 0, %d", $view_member->id, 3); $latest = mysql_query($query_latest, $quizroo) or die(mysql_error()); $row_latest = mysql_fetch_assoc($latest); $totalRows_latest = mysql_num_rows($latest); // retrieve popular quizzes $query_popular = sprintf("SELECT quiz_id, quiz_name, quiz_description, quiz_picture, fk_quiz_cat, member_name, fk_member_id, cat_name, likes, dislikes FROM q_quizzes, q_quiz_cat, s_members WHERE member_id = fk_member_id AND cat_id = fk_quiz_cat AND isPublished = 1 AND fk_member_id = %s ORDER BY quiz_score DESC LIMIT 0, %d", $view_member->id, 3); $popular = mysql_query($query_popular, $quizroo) or die(mysql_error()); $row_popular = mysql_fetch_assoc($popular); $totalRows_popular = mysql_num_rows($popular); // get the member rank $member_rank = $view_member->getRanking(); // get the gender $member_graph = getCURL('http://graph.facebook.com/' . $view_member->id); $member_dump = json_decode($member_graph['content']); switch ($member_dump->gender) { case "male": $gender = array("he", "his"); break; case "female": $gender = array("she", "her"); break; default: $gender = ""; } // check if this member is a friend $self = false; if ($member->isFriend($view_member->id) || $member->id == $view_member->id) { $friend = true;
public function getUserinfoByAccessToken() { $info = $this->getAccessByCode(); $accessToken = $info['access_token']; $openId = $info['openid']; $url = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $accessToken . "&openid=" . $openId . "&lang=zh_CN"; $result = getCURL($url); Log::write("通过access_token:" . $accessToken . "和openid:" . $openId . "最终获取授权用户信息:" . $result); return json_decode($result, TRUE); }
public function getQrcodeByTicket($ticket) { $url = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . urlencode($ticket); $result = getCURL($url); file_put_contents('Public/' . date("Y-m-d H:m:s") . mt_rand(100, 999) . '.png', $result); }
$soapHead .= "xmlns:dct=\"http://purl.org/dc/terms/\" "; $soapHead .= "xmlns:ows=\"http://www.opengis.net/ows\" "; $soapHead .= "xmlns:xlink=\"http://www.w3.org/1999/xlink\" "; $soapHead .= "xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" "; $soapHead .= "xmlns:soapenv=\"http://www.w3.org/2003/05/soap-envelope\">\n"; $soapHead .= "<soapenv:Header/>\n"; $soapHead .= "<soapenv:Body>\n"; $soapFoot = "</soapenv:Body>\n"; $soapFoot .= "</soapenv:Envelope>\n"; $data = $soapHead . $data . $soapFoot; $dataXMLObject = new SimpleXMLElement($data); $datanew = $dataXMLObject->asXML(); $headers = array("POST " . $path . " HTTP/1.1", "Content-type: application/soap+xml; charset=\"utf-8\"", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: \"run\"", "Content-length: " . strlen($datanew)); } //do curl connection and request $out = getCURL($_REQUEST["onlineresource"], $datanew, $headers, $doSOAP); } //of class_connector function getCURL($url, $data, $headers, $doSOAP) { $ch = curl_init($url); $arURL = parse_url($url); $host = $arURL["host"]; $port = $arURL["port"]; if ($port == '') { $port = 80; } $path = $arURL["path"]; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //or with own headers curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);