PHP 클래스 HttpRequestService, thinksns

파일 보기 프로젝트 열기: medz/thinksns-4 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$_encode default is json
$api_url #Set up the API root URL.
$connecttimeout #Set connect timeout.
$decodeFormat Only support json & xml for extension
$format #Response format.
$http_code #Contains the last HTTP status code returned.
$http_header
$http_info #Contains the last HTTP headers returned.
$ssl_verifypeer #Verify SSL Cert.
$timeout #Set timeout default.

공개 메소드들

메소드 설명
_DELETE ( $url, $params = null, $username = null, $password = null ) : RESTClient DELETE wrapper for delete data
_GET ( $url, $params = null, $username = null, $password = null ) : RESTClient GET wrapper for get data
_POST ( $url, $params = null, $username = null, $password = null, $contentType = null ) : RESTClient POST wrapper for insert data
_POST_FOPEN ( $url, $params = null, $username = null, $password = null, $contentType = null )
_PUT ( $url, $params = null, $username = null, $password = null, $contentType = null ) : RESTClient PUT wrapper for update data
__construct ( )
_photoUpload ( $url, $postdata, $files )
call ( $url, $method, $postFields = null, $username = null, $password = null, $contentType = null ) : RESTClient Execute calls
call_fopen ( $url, $method, $postFields = null, $username = null, $password = null, $contentType = null )
close ( ) Closes the connection and release resources
convertEncoding ( $source, $in, $out )
create_post_body ( $post_params )
do_post_request ( $url, $postdata, $files ) : mixed POST wrapper,不基于curl函数,环境可以不支持curl函数
getHeader ( $ch, $header ) Get the header info to store.
get_http_url ( ) parses the url and rebuilds it to be scheme://host/path
json_foreach ( $jsonArr ) 将stdclass object转换成数组,并转换编码
objectToArray ( $obj )
parseResponse ( $resp, $ext = '' ) * Parse response, including json, xml, plain text
setAuthorizeInfo ( $username, $password ) Set the authorize info for Basic Authentication
setContentType ( string $contentType ) Set the Content-Type of the request to be send Format like "application/json" or "application/xml" or "text/plain" or other
setDecodeFormat ( $format = null ) : boolean Sets the format type to be decoded
setEncode ( $encode )
setFormat ( $format = null ) : boolean Sets the format type to be extension
setMethod ( $method ) Set the Request HTTP Method
setNotFollow ( ) : RESTClient Settings that won't follow redirects
setParameters ( $params ) Set Parameters to be send on the request It can be both a key/value par array (as in array("key"=>"value")) or a string containing the body of the request, like a XML, JSON or other Proper content-type should be set for the body if not a array
setURL ( $url ) Sets the URL to be Called
to_postdata ( ) builds the data one would send in a POST request
to_url ( ) builds a url usable for a GET request
xml_decode ( $data, $toArray = false ) * XML decode

메소드 상세

_DELETE() 공개 메소드

DELETE wrapper for delete data
public _DELETE ( $url, $params = null, $username = null, $password = null ) : RESTClient
$url String
$params mixed
$username String
$password String
리턴 RESTClient

_GET() 공개 메소드

GET wrapper for get data
public _GET ( $url, $params = null, $username = null, $password = null ) : RESTClient
$url String
$params mixed
$username String
$password String
리턴 RESTClient

_POST() 공개 메소드

POST wrapper for insert data
public _POST ( $url, $params = null, $username = null, $password = null, $contentType = null ) : RESTClient
$url String
$params mixed
$username String
$password String
$contentType String
리턴 RESTClient

_POST_FOPEN() 공개 메소드

public _POST_FOPEN ( $url, $params = null, $username = null, $password = null, $contentType = null )

_PUT() 공개 메소드

PUT wrapper for update data
public _PUT ( $url, $params = null, $username = null, $password = null, $contentType = null ) : RESTClient
$url String
$params mixed
$username String
$password String
$contentType String
리턴 RESTClient

__construct() 공개 메소드

public __construct ( )

_photoUpload() 공개 메소드

public _photoUpload ( $url, $postdata, $files )

call() 공개 메소드

Execute calls
public call ( $url, $method, $postFields = null, $username = null, $password = null, $contentType = null ) : RESTClient
$url String
$method String
$postFields String
$username String
$password String
$contentType String
리턴 RESTClient

call_fopen() 공개 메소드

public call_fopen ( $url, $method, $postFields = null, $username = null, $password = null, $contentType = null )

close() 공개 메소드

Closes the connection and release resources
public close ( )

convertEncoding() 공개 정적인 메소드

public static convertEncoding ( $source, $in, $out )

create_post_body() 공개 메소드

public create_post_body ( $post_params )

do_post_request() 공개 메소드

POST wrapper,不基于curl函数,环境可以不支持curl函数
public do_post_request ( $url, $postdata, $files ) : mixed
리턴 mixed

getHeader() 공개 메소드

Get the header info to store.
public getHeader ( $ch, $header )

get_http_url() 공개 메소드

parses the url and rebuilds it to be scheme://host/path
public get_http_url ( )

json_foreach() 공개 메소드

将stdclass object转换成数组,并转换编码
public json_foreach ( $jsonArr )

objectToArray() 공개 정적인 메소드

public static objectToArray ( $obj )

parseResponse() 공개 메소드

* Parse response, including json, xml, plain text
public parseResponse ( $resp, $ext = '' )
$resp String
$ext String, including json/xml

setAuthorizeInfo() 공개 메소드

Set the authorize info for Basic Authentication
public setAuthorizeInfo ( $username, $password )
$username String
$password String

setContentType() 공개 메소드

Set the Content-Type of the request to be send Format like "application/json" or "application/xml" or "text/plain" or other
public setContentType ( string $contentType )
$contentType string

setDecodeFormat() 공개 메소드

Sets the format type to be decoded
public setDecodeFormat ( $format = null ) : boolean
$format String
리턴 boolean

setEncode() 공개 메소드

public setEncode ( $encode )

setFormat() 공개 메소드

Sets the format type to be extension
public setFormat ( $format = null ) : boolean
$format String
리턴 boolean

setMethod() 공개 메소드

Set the Request HTTP Method
public setMethod ( $method )
$method String

setNotFollow() 공개 메소드

Settings that won't follow redirects
public setNotFollow ( ) : RESTClient
리턴 RESTClient

setParameters() 공개 메소드

Set Parameters to be send on the request It can be both a key/value par array (as in array("key"=>"value")) or a string containing the body of the request, like a XML, JSON or other Proper content-type should be set for the body if not a array
public setParameters ( $params )
$params mixed

setURL() 공개 메소드

Sets the URL to be Called
public setURL ( $url )
$url String

to_postdata() 공개 메소드

builds the data one would send in a POST request
public to_postdata ( )

to_url() 공개 메소드

builds a url usable for a GET request
public to_url ( )

xml_decode() 공개 정적인 메소드

* XML decode
public static xml_decode ( $data, $toArray = false )
$data String
$toArray boolean, true for make it be array

프로퍼티 상세

$_encode 공개적으로 프로퍼티

default is json
public $_encode

$api_url 공개적으로 프로퍼티

#Set up the API root URL.
public $api_url

$connecttimeout 공개적으로 프로퍼티

#Set connect timeout.
public $connecttimeout

$decodeFormat 공개적으로 프로퍼티

Only support json & xml for extension
public $decodeFormat

$format 공개적으로 프로퍼티

#Response format.
public $format

$http_code 공개적으로 프로퍼티

#Contains the last HTTP status code returned.
public $http_code

$http_header 공개적으로 프로퍼티

public $http_header

$http_info 공개적으로 프로퍼티

#Contains the last HTTP headers returned.
public $http_info

$ssl_verifypeer 공개적으로 프로퍼티

#Verify SSL Cert.
public $ssl_verifypeer

$timeout 공개적으로 프로퍼티

#Set timeout default.
public $timeout