PHP ucloud biz API 호출

Jmnote (토론 | 기여)님의 2018년 6월 4일 (월) 16:16 판

1 개요

PHP ucloud biz API 호출
function call_ucloud_biz_api($args) {
	$endpoint = 'https://api.ucloudbiz.olleh.com/server/v2/client/api';
	$apikey = '';
	$secret = '';
	
	$args['apikey'] = $apikey;
	$args['response'] = 'json';

	$params = [];
	$keys = array_keys( $args );
	sort( $keys );
	
	foreach( $keys as $k ) $params[] = $k . '=' . rawurlencode( $args[$k] );
	$query = implode( '&', $params );
	
	$signature = rawurlencode( base64_encode( hash_hmac( 'sha1', strtolower($query), $secret, true ) ) );
	$query .= "&signature=$signature";
	$url = $endpoint . '?' . $query;
	
	if ( !filter_var($url, FILTER_VALIDATE_URL) ) {
		return false;
	}
	//return $url;
	//return file_get_contents($url);
	//return json_decode(shell_exec("curl --globoff '$url'"), true);
	return json_decode(file_get_contents($url), true);
}

2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}