Example #1
0
function OAuthWeixin($callback)
{
    $isWeixinBrowser = isWeixinBrowser();
    $info = get_token_appinfo();
    if (!$isWeixinBrowser || empty($info['appid'])) {
        redirect($callback . '&openid=-1');
    }
    $param['appid'] = $info['appid'];
    if (!isset($_GET['getOpenId'])) {
        $param['redirect_uri'] = $callback . '&getOpenId=1';
        $param['response_type'] = 'code';
        $param['scope'] = 'snsapi_base';
        //$param ['scope'] = 'snsapi_userinfo';
        $param['state'] = 123;
        $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?' . http_build_query($param) . '#wechat_redirect';
        redirect($url);
    } elseif ($_GET['state']) {
        $param['secret'] = $info['appsecret'];
        $param['code'] = I('code');
        $param['grant_type'] = 'authorization_code';
        $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?' . http_build_query($param);
        //$content = file_get_contents($url);
        $content = getCurl($url);
        $content = json_decode($content, true);
        redirect($callback . '&openid=' . $content['openid']);
    }
}
 function geturlinfoback($url)
 {
     $data = getCurl($url);
     //通过自定义函数getCurl得到https的内容
     $resultArr = json_decode($data, true);
     //转为数组
     return $resultArr;
 }
Example #3
0
 /**
  * Subscribe to a topic (creates a webhook).
  *
  * @return void
  */
 public function subscribe()
 {
     getAuthentication()->requireAuthentication();
     $params = $_POST;
     $params['verify'] = 'sync';
     if (isset($params['callback']) && isset($params['mode']) && isset($params['topic'])) {
         $urlParts = parse_url($params['callback']);
         if (isset($urlParts['scheme']) && isset($urlParts['host'])) {
             if (!isset($urlParts['port'])) {
                 $port = '';
             }
             if (!isset($urlParts['path'])) {
                 $path = '';
             }
             extract($urlParts);
             $challenge = uniqid();
             $queryParams = array();
             if (isset($urlParts['query']) && !empty($urlParts['query'])) {
                 parse_str($urlParts['query'], $queryParams);
             }
             $queryParams['mode'] = $params['mode'];
             $queryParams['topic'] = $params['topic'];
             $queryParams['challenge'] = $challenge;
             if (isset($params['verifyToken'])) {
                 $queryParams['verifyToken'] = $params['verifyToken'];
             }
             $queryString = '';
             if (!empty($queryParams)) {
                 $queryString = sprintf('?%s', http_build_query($queryParams));
             }
             $url = sprintf('%s://%s%s%s%s', $scheme, $host, $port, $path, $queryString);
             $ch = curl_init($url);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $handle = getCurl()->addCurl($ch);
             // verify a 2xx response and that the body is equal to the challenge
             if ($handle->code >= 200 && $handle->code < 300 && $handle->data == $challenge) {
                 $apiWebhook = $this->api->invoke('/webhook/create.json', EpiRoute::httpPost, array('_POST' => $params));
                 if ($apiWebhook['code'] === 200) {
                     header('HTTP/1.1 204 No Content');
                     getLogger()->info(sprintf('Webhook successfully created: %s', json_encode($params)));
                     return;
                 }
             }
             $message = sprintf('The verification call failed to meet requirements. Code: %d, Response: %s, Expected: %s, URL: %s', $handle->code, $handle->data, $challenge, $url);
             getLogger()->warn($message);
         } else {
             $message = sprintf('Callback url was invalid: %s', $params['callback']);
             getLogger()->warn($message);
         }
     } else {
         $message = sprintf('Not all required parameters were passed in to webhook subscribe: %s', json_encode($params));
         getLogger()->warn($message);
     }
     header('HTTP/1.1 400 Bad Request');
     echo $message;
 }
Example #4
0
function getUserData($website, $user, $from = "0000-00-00 00:00:00", $to = "9999-99-99 23-59-59")
{
    $ch = getCurl();
    if (!empty($from) && !empty($to)) {
        $params = "website={$website}&user={$user}";
    } else {
        $params = "website={$website}&user={$user}&from={$from}&to={$to}";
    }
    //print_r($params);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    $response = curl_exec($ch);
    curl_close($ch);
    return json_decode($response);
}
Example #5
0
function post($id, $key, $endpoint, $format, $dataId, $data)
{
    if (!isset($dataId, $data)) {
        return null;
    }
    try {
        // calculate API signature
        $signature = getSignature("", $key);
        // create the curl object.
        // - POST always requires the object's id
        $curl = getCurl($id, $key, $signature, "{$endpoint}/{$dataId}", "", $format);
        // set extra curl options required by POST
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        // POST something
        $curl_result = curl_exec($curl);
        error_log($curl_result);
        curl_close($curl);
        return $curl_result;
    } catch (Exception $e) {
        error_log('Error: ' + $e);
    }
}
function getPage($url)
{
    $ch = getCurl();
    curl_setopt($ch, CURLOPT_URL, $url);
    return curl_exec($ch);
}
Example #7
0
$rp_url = 'https://money.yandex.ru/api/request-payment';
$rp_params = array('pattern_id' => 'p2p', 'to' => $to, 'amount' => $amount, 'message' => $message, 'comment' => $comment);
$rp_params = http_build_query($rp_params);
$rp_headers = array(0 => 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8;', 1 => 'Authorization: Bearer ' . $token);
$rp_result = getCurl($rp_url, $rp_params, 0, 0, $rp_headers);
$rp_res = json_decode($rp_result['content'], 1);
/************************************************/
if (!isset($rp_res['status']) || $rp_res['status'] != 'success') {
    header('Location: ' . SITE_URL . 'ishop/ym.fail');
    exit;
}
////////////////////////////////////////////////
////////////////////////////////////////////////
/////////////////PROCESS-PAYMENT////////////////
////////////////////////////////////////////////
$pp_url = 'https://money.yandex.ru/api/process-payment';
$pp_params = array('request_id' => $rp_res['request_id']);
$pp_params = http_build_query($pp_params);
$pp_headers = array(0 => 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8;', 1 => 'Authorization: Bearer ' . $token);
$pp_result = getCurl($pp_url, $pp_params, 0, 0, $pp_headers);
$pp_res = json_decode($pp_result['content'], 1);
/************************************************/
if (isset($pp_res['status']) && $pp_res['status'] == 'success') {
    unset($_SESSION['ym']);
    header('Location: ' . SITE_URL . 'ishop/order');
    exit;
} else {
    header('Location: ' . SITE_URL . 'ishop/ym.fail');
    exit;
}
////////////////////////////////////////////////
Example #8
0
header("content-type:text/html;charset=utf-8");
$url = 'mybbslocal.jason.com/index.php/Plate/index.html';
function getCurl($url)
{
    $user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    // 设置访问的ip
    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
    // 模拟用户使用的浏览器
    @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    //使用自动跳转
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    //设置超时时间
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    // 自动设置referer
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\\COOKIE.TXT');
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    $result = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);
    return $info;
}
//echo $_SERVER['HTTP_USER_AGENT'];
$r = getCurl($url);
$arr = array('url资源网络地址' => $r['url'], 'content_type内容编码' => $r['content_type'], '“http_code” //HTTP状态码 ' => $r['http_code'], 'header_size//header的大小' => $r['header_size'], '“request_size” //请求的大小 ' => $r[request_time], 'filetime文件创建时间' => $r['filetime'], 'ssl_verify_result//ssl验证结果' => $r['ssl_verify_result'], 'redirect_count//跳转技术' => $r['redirect_count'], 'total_time//总耗时' => $r['total_time'], '“connect_time” //等待连接耗时' => $r['connect_time'], '“pretransfer_time” //传输前准备耗时' => $r['pretansfer_time'], '“size_upload” //上传数据的大小' => $r['size_upload'], '“size_download” //下载数据的大小 ' => $r['size_download'], '“speed_upload” //上传速度 ' => $r['speed_upload'], '“download_content_length”//下载内容的长度 ' => $r['download_content_length'], '“upload_content_length” //上传内容的长度' => $r['upoad_content_length'], '“starttransfer_time” //开始传输的时间 ' => $r['starttransfer_time'], '“redirect_time”//重定向耗时 ' => $r['redirect_time']);
echo '<pre>';
print_r($r);
Example #9
0
function getUrl($url, $sessionid, $user)
{
    if ($sessionid && $user) {
        $html = getCurl($url, "PHPSESSID={$sessionid}", $user);
        //echo $html; exit;
    } else {
        $html = file_get_contents($url);
    }
    return $html;
}
Example #10
0
function initDoodle($key, $secret)
{
    //
    // 1. Get a token.
    //
    echo "<hr><b>Get token</b><br>";
    $in_params['oauth_consumer_key'] = $key;
    $in_params['oauth_consumer_secret'] = $secret;
    $url = "http://doodle.com/api1/oauth/requesttoken";
    $out = getCurl($url, $in_params);
    // print_r($out);
    //
    // 2. Access the token.
    //
    echo "<hr><b>Access token</b><br>";
    $in_params['oauth_token'] = $out['oauth_token'];
    $in_params['oauth_token_secret'] = $out['oauth_token_secret'];
    $url = "http://doodle.com/api1/oauth/accesstoken";
    $out = getCurl($url, $in_params);
    // print_r($out);
    $in_params['oauth_token'] = $out['oauth_token'];
    $in_params['oauth_token_secret'] = $out['oauth_token_secret'];
    return $in_params;
}
 /**
  * get 验证access_token是否有效
  */
 public function isValidAccessToken($access_token)
 {
     if (empty($access_token)) {
         die('The access_token cannot be empty');
     }
     $url = "https://api.weixin.qq.com/sns/auth?access_token=" . $access_token . "&openid=" . $this->openid;
     $res = json_decode(getCurl($url), true);
     if ($res['errcode'] == 0) {
         return true;
     } else {
         return false;
     }
 }
Example #12
0
 public function proxySend($proxy_url, $proxy_key)
 {
     if (!$proxy_url || !$proxy_key) {
         return false;
     }
     $self_proxy_key = get_option('ext_function_mail_proxy_selfkey');
     if ($self_proxy_key == $proxy_key) {
         return false;
     }
     //can not proxy to self;
     $req = "page_id=mail-proxy&proxy_key={$proxy_key}";
     $req .= "&flag=" . $this->flag;
     $req .= "&smtpserver=" . $this->smtpserver;
     $req .= "&smtpserverport=" . $this->smtpserverport;
     $req .= "&smtpusermail=" . $this->smtpusermail;
     $req .= "&smtpuser="******"&smtppass="******"&smtpemailto=" . urlencode($this->smtpemailto);
     $req .= "&mailsubject=" . urlencode($this->mailsubject);
     $req .= "&mailbody=" . urlencode($this->mailbody);
     $response = postCurl($proxy_url, $req);
     if (!$response) {
         $response = getCurl($proxy_url, $req);
     }
     if ($proxy_key != trim($response)) {
         return false;
     }
     return $response;
 }
//Includes the Header template.
include './includes/header.php';
//Includes the CURL functions
include_once './includes/curlFun.php';
//Includes the Databse Utilities
include_once './includes/dbUtil.php';
$url = filter_input(INPUT_POST, 'url');
//Checks to see if Post Request to add url to database
if (isPostRequest()) {
    if (filter_var($url, FILTER_VALIDATE_URL)) {
        if (searchDB($url)) {
            echo '<h3> Site is already in system.</h3>';
        } elseif (!filter_var($url, FILTER_VALIDATE_URL)) {
            echo '<h3>URL is not valid!</h3>' . '<h5>Please use "http://www.[SITE].[com,edu,...]/" format</h5>';
        } else {
            $pageData = getCurl($url);
            echo "<h3> {$url}</h3>";
            $links = matchURL($pageData);
            $message = addData($url, $links);
            $url = "";
        }
    }
}
?>

        <?php 
if (isset($message)) {
    include_once './includes/linkTable.php';
    ?>

            <br/>
Example #14
0
require __DIR__ . '/../src/CurlCmdPhp.php';
//$autoload_files = array( __DIR__ . '/../vendor/autoload.php',
//    __DIR__ . '/../../../autoload.php');
//
//foreach($autoload_files as $autoload_file)
//{
//    if(!file_exists($autoload_file)) continue;
//    require_once $autoload_file;
//}
// end autoloader finder
$cmdstring = readline('Curl command line: ');
$output_file = readline("Output filename ( mycurl.php ): ");
if ($cmdstring == '') {
    $cmdstring = "curl 'http://posttestserver.com/post.php?dir=curl-cmd-php&q-destination=Paris%2C+France&destination-id=504261&as-shown=false&q-localised-check-in=18%2F02%2F2016&q-localised-check-out=19%2F02%2F2016&q-rooms=1&q-room-0-adults=2&q-room-0-children=0&page-name=HomePage' -H 'DNT: 1' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8,es;q=0.6' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Referer: http://www.hotels.com/' -H 'Cookie: h_darq=f; guid=8532c7cc-98e4-4f10-9e45-75ef2ea30be0; searchReturningUser=true; channel=DC; 30dlt=seo.hcom.mx.z.www.google.com.mx; propertyReturningUser=true; SSSC=3.G6248991744302678837.3|1963.1874:1975.18819:2032.19434:2037.19449:214.20653:2158.20678:2182.20825:2188.20897:2190.20924:2191.20926:2199.21122:2203.21149:2215.21268:2218.21285:2220.21293:2223.21301:2228.21327:2231.21345:2232.21349:2234.21360:2235.21369:2248.21471:2257.21558:2261.21628; SESSID=RS75X9-Aa18MUXN1QDyxLwsLjc.prod1-lpa-15; SSID=CACWXh1QAQQAAADi4LhWNYOCA-LguFYDAAAAAAAoSrFX_PrDVgCSjNUIAAV8VAAA_PrDVgEAtwcABYNJAAD8-sNWAQCXCAAHglIAAPz6w1YBANEIAAc2VAAA_PrDVgEAtAgAB09TAADi4LhWAwCMCAAFoVEAAPz6w1YBAJsIAAWdUgAA_PrDVgEArAgABS1TAAD-sNWAQCqCAAFJVMAAPz6w1YBAPAHAAXqSwAA_PrDVgEAuwgABXlTAAD8-sNWAQCOCAAHvFEAAOLguFYDALoIAAVwUwAA_PrDVgEArwgABTVTAAD8-sNWAQCGCAAFWVEAAPz6w1YBAMgIAAXfUwAA_PrDVgEA9QcABflLAAD8-sNWAQC4CAAFZVMAAPz6w1YBALcIAAVhUwAA_PrDVgEAYggABa1QAAD8-sNWAQCnCAAFFFMAAPz6w1YBAKsHAAdgSQAA4uC4VgMAjwgAB75RAADi4LhWAwBuCAAHxlAAAOLguFYDAF4IAAA; SSRT=SvzDVgIDAQ; homepage_search_data=QWJ1IERoYWJpLCBVbml0ZWQgQXJhYiBFbWlyYXRlcw..%2F%2F24%2F02%2F2016%2F%2F25%2F02%2F2016%2F%2F2%2F%2Fdd%2FMM%2Fyyyy%2F%2F1634727; mvthistory=eJxNVTmSXDEIvVGXWMSibMqJA085ce547uDDG3091FMd%2FCcEAh5La7xG%2Fb5ohR40V3J96fUlK%2BNlr7FIthYvHuPlj7Ytptz6i3keO1k848VbZNu8RLrY%2FdGSsrQt4sJi55qXTDrXbniElg5%2BZDoQEC%2BN2Raaun1UCLPwPFjXHOMxmkKlSWtOXMkyOj48ByxzBcdJhCvvJ7mxwk5C4QNfwpfxleebFdcTTBRRfqCv1HlupxwRLRrjvEiDtAHCysJPqMAWnSAN%2BCeadhXI%2FKXHE1EeV8SKF2gfgiBNQkl1HxgH2YeO7TnoqXLVkmRQV6wwghVGAbaQ4VOMAaIlHY52lkpXYg2ia0nK8spEXsoBDQFXaorrnZUGyNCE3zlmA28QXevCeGYSDHdHAOSbramIdU68YuhnMo43S%2Bbw5gOBemfplaU8QOKS5wq3rnDrLre0jmko0K85vEYTHGKXqph8bKtE3Y4FQGoEKEmG01Rcpd2BoYRTHpHNE4%2BEkIh67Lk4gNDReUT7cOktnHeyqYdy64S9cerF3HWXjXth8HgrMHWgzHYHnncTEwx3cz6G3Zks9O2Wuql9H96%2BhduM%2BSTAGyNvOTRvcEePRRGiWHty7hVTWG7y4q0Zgq1S6w%2FNx5MZQPgGOu1uhsKteZjeq3NCktrAGpxmqbU6GuDZKpq1C9oYtqbfhIqUrctr3RE%2B7IbnNU7NkmOA2fnObeHc%2FX7w3TwbtzK6j722enPihmfn%2Fi8QKDR7eycDUIP751AYcQaNK4yOLbA6OKQl9vYbBtsc7%2FrmKdCjkH64qqbiBlcyG9xZlDH7n8xGg%2BzmlnH%2F58LbheyBO0KsyOrVw4AwmlP4vPbv54%2Ffn39%2Fffz%2BPwP63WPjA%3D%3D%212161.0.0; s_cc=true; SSPV=IFEAAAAAAAAABQAAAAAAAAAAAAMAAAAAAAA; user=QSplbl9NWHxIQ09NX0xBVEFNIUIqVVNEIUoqNw..; asc=1; s_vi=[CS]v1|2B5C7072051D0983-400019092001A296[CE]; SSLB=1; AFFLB=A; s_fid=0E133BF5930473A5-31C615679FBF9693; s_sq=hotelsallprod%3D%2526pid%253Dhome%252520page%2526pidt%253D1%2526oid%253DSearch%2526oidt%253D3%2526ot%253DSUBMIT' -H 'Connection: keep-alive' --data 'postvar1=hello&postvar2=world' --compressed";
}
if ($output_file == '') {
    $output_file = 'mycurl.php';
}
echo "Using Command: {$cmdstring}\n";
$CurlCmd = new \projectivemotion\CurlCmdPhp();
$CurlCmd->setCmdLine($cmdstring);
$php_code = $CurlCmd->generateCode();
file_put_contents($output_file, "<" . "?php\n\n// generated by curl-cmd-php (http://github.com/projectivemotion/curl-cmd-php/)\n\n" . $php_code);
echo "\nPHP Code written to {$output_file}\n";
$do_test_file = readline("Test (execute) php file? [Y/n]: ");
if ($do_test_file == 'Y' || $do_test_file == 'y') {
    echo "Now testing {$output_file}\n";
    require $output_file;
    $content = getCurl(TRUE);
    echo "\n\n\nCurl Returned: \n\n{$content}\n\n";
}
Example #15
0
 public function deleteMenu($accessToken)
 {
     //$accessToken = $this->getAccessToken();//获取access_token
     $menuPostUrl = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=" . $accessToken;
     //POST的url
     error_log(getCurl($menuPostUrl));
     // $menu = dataPost($menuPostString, $menuPostUrl);//将菜单结构体POST给微信服务器
 }
Example #16
0
function doGet($url)
{
    $ch = getCurl($url);
    $result = curl_exec($ch);
    // TODO - check for rate limiting?
    return json_decode($result);
}
Example #17
0
    //	print_r($result);
    if (!is_array($output)) {
        return FALSE;
    } else {
        return array($output, $result);
    }
}
///////////////////////////
///////////////////////////
// DO ACTUAL CHECK
// function getCurl($session, $thisServer) {
function getCurl($lat, $lon)
{
    $curl = flushCurl();
    $url = "http://forecast.weather.gov/MapClick.php?lat=" . $lat . "&lon=" . $lon . "&unit=0&lg=english&FcstType=dwml";
    // 	print "URL: $url\n";
    curl_setopt($curl, CURLOPT_URL, "{$url}");
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
    $outputRAW = curl_exec($curl);
    $output = json_decode(json_encode(simplexml_load_string($outputRAW)), TRUE);
    return $output;
}
///////////////////////////
$weatherArray = getCurl($lat, $lon);
//print_r($weatherArray['data'][0]['parameters']['wordedForecast']['text']);
$city = $weatherArray['data'][0]['location']['city'];
$today = $weatherArray['data'][0]['parameters']['wordedForecast']['text'][0];
$tonight = $weatherArray['data'][0]['parameters']['wordedForecast']['text'][1];
print $day . "'s forecast for {$city} is ";
print strtolower($today) . "\n";
print "Tonight will be " . strtolower($tonight) . "\n";