OPEN API

Open API

POST direct_ePosition/new

Resource URL METHOD
http://eposition.com/v1/add/?key=mbXDTEbuBGCeE3wBZK5rEI POST

Parameters

Parameter Value Description
epid String ePosition ID to be inquired.
Alphabet, number, dash(‘.’) and underscore (‘-‘) are allowed.
The number of chaterers are limited by 50.
Example Values: starwars#eposition.com, starwars
longUrl String Example Values: www.starwars.com
description String Example Values: STARWARS

Error Code

status msg
200 Success
400 Fail
600 Invaild ePosition ID Format

 

Samples (PHP, JSON)

<?php
define("EPOSITION_API_KEY","mbXDTEbuBGCeE3wBZK5rEI");
define("EPOSITION_API_URL","http://eposition.com/v1/add/?key=" . EPOSITION_API_KEY);

function ePositionReg($epid, $longUrl, $description)
{
	$curl = curl_init();
	$curl_option = array(
		CURLOPT_CONNECTTIMEOUT=> 5
		,CURLOPT_TIMEOUT=> 7
		,CURLOPT_RETURNTRANSFER=> true
		,CURLOPT_HEADER=> false
		,CURLOPT_HTTPHEADER=>array('Content-Type:application/json')
	);

	$curl_option[CURLOPT_SSL_VERIFYPEER] = false;
	$curl_option[CURLOPT_POST] = true;
	$curl_option[CURLOPT_POSTFIELDS] = json_encode(array("epid"=>$epid,"longUrl"=>$longUrl,"description"=>$description));
	$curl_option[CURLOPT_URL] = EPOSITION_API_URL;

	curl_setopt_array($curl, $curl_option);
	$curl_result = curl_exec($curl);

	if($curl_result !== false && curl_errno($curl) === 0)
	{
		$curl_result_array = json_decode($curl_result, true);
		$status = $curl_result_array['status'];
		$msg = $curl_result_array['msg'];
	}

	curl_close($curl);
	return $curl_result;
}

header("Content-Type: application/json");

$epid = "starwars#eposition.com";
$longUrl = "www.starwars.com";
$description = "STARWARS";
echo ePositionReg($epid, $longUrl, $description);
?>

 

Example Result :

{ 
	"epid":"starwars#eposition.com",
	"status":"200",
	"msg":"success",
	"url":"http://www.starwars.com",
	"description":"STARWARS",
	"short_url":"http://eposition.com/iot/starwars"
}

Request URL

Resource URL METHOD
http://eposition.com/v1/eposition/?epid=[ePosition ID]&answer=[xml, json] GET

Request Parameter

Parameter Value Description
epid String ePosition ID to be inquired.
Alphabet, number, dash(‘.’) and underscore (‘-‘) are allowed.
The number of chaterers are limited by 50.
answer String Response data format : xml or json
(xml : XML, json : JSON, Default : xml)

Response Field

Key Description Type
status state code String
epid ePosition ID String
open Open or Not Open(Open : True, Not Open : False) String
url url String
short_url short url String

 

Example Result

XML

<?xml version='1.0' encoding='UTF-8'?>
<eposition>
<status>200</status>
<epid>
<![CDATA[starwars#eposition.com]]>
</epid>
<open>True</open>
<url>
<![CDATA[http://www.starwars.com]]>
</url>
<short_url>
<![CDATA[http://eposition.com/iot/starwars]]>
</short_url>
</eposition>

JSON

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"eposition": {
"status": "200",
"epid": "starwars#eposition.com",
"open":"True",
"url": "http://www.starwars.com",
"short_url":"http://eposition.com/iot/starwars"
}
}

Error Code

status error_msg
200 Success
400 Fail (Not Found ePosition ID)
600 Invaild ePosition ID Format

 

Samples (PHP, JSON)

<?php
define("EPOSITION_API_URL","http://eposition.com/v1/eposition/");

function ePositionLink($e) {
$epid = urlencode($e);
$api_url_json = EPOSITION_API_URL.'?epid='.$epid.'&answer=json';
$str = file_get_contents($api_url_json);
$json = json_decode($str, true);
if ($json['eposition']['status']=='200' && $json['eposition']['open'] == 'True') {
$result = "<a href='".urldecode($json['eposition']['url'])."' target='_blank'>".urldecode($epid)."</a>";
//echo $json['eposition']['epid'];
//echo $json['eposition']['short_url'];
} else {
$result = $json['eposition']['open'];
}
return $result;
}
echo ePositionLink('starwars#eposition.com');
?>

 

Result :

starwars#eposition.com

Leave a Reply

Your email address will not be published. Required fields are marked *