Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php jdk #38

Open
GoogleCodeExporter opened this issue Jan 22, 2016 · 1 comment
Open

php jdk #38

GoogleCodeExporter opened this issue Jan 22, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link

class NplRequest{
    private $fudanUrl = "http://jkx.fudan.edu.cn/fudannlp/";
    private $connecttimeout = 20;
    private $timeout = 10;
    private $ssl_verifypeer = FALSE;

    public $http_code;
    public $http_info = array();
    public $url;

    function npl($key,$str){
        $response = $this->http($this->fudanUrl.$key."/".$str,"GET","");
        return $response;
    }

    function http($url,$method,$param){
        $ci = curl_init();
        curl_setopt($ci, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
        curl_setopt($ci, CURLOPT_CONNECTTIMEOUT, $this->connecttimeout);
        curl_setopt($ci, CURLOPT_TIMEOUT, $this->timeout);
        curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ci, CURLOPT_ENCODING, "");
        curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, $this->ssl_verifypeer);
        curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, 1);
        curl_setopt($ci, CURLOPT_HEADER, FALSE);

        if($method == "POST"){
            curl_setopt($ci, CURLOPT_POST, TRUE);
        }else{
            $url = "{$url}?{$param}";
        }
        curl_setopt($ci, CURLOPT_URL, $url );
        curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE );

        $response = curl_exec($ci);
        $this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
        $this->http_info = array_merge($this->http_info, curl_getinfo($ci));
        $this->url = $url;
        curl_close ($ci);
        return $response;
    }
}

Original issue reported on code.google.com by tiny051...@gmail.com on 13 May 2013 at 9:24

@GoogleCodeExporter
Copy link
Author

thx:)

Original comment by xipeng...@gmail.com on 14 May 2013 at 3:19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant