NAV

Social Media Account(Last Updated : 01/04/2017)

You should register your social networking account(s) and page(s) before publishing content. You can register your Facebook account, Facebook page, or Twitter account.

Methods

PUT /rest/v1/{user_name}/account/sns
GET /rest/v1/{user_name}/account/sns
GET /rest/v1/{user_name}/account/sns/{sns_id}
GET /rest/v1/{user_name}/account/sns/{sns_id}/page
GET /rest/v1/{user_name}/account/sns/{sns_id}/page/{page_id}
DELETE /rest/v1/{user_name}/account/sns/{sns_id}
DELETE /rest/v1/{user_name}/account/sns/{sns_id}/page/{page_id}

PUT SNS Account

Register a Facebook account, Facebook page, or Twitter account.

When you perform a PUT SNS Account, you will receive an authentication_url. After logging into Facebook or Twitter via the authentication_url, you can complete the register process. You can then verify if the request was successful.

Resource Information

Response Formats JSON
Allowed Methods PUT
URL http://api.trumpia.com/rest/v1/{user_name}/account/sns
{user_name} Your account username (this can be found in the Account Settings page after logging in.)

Header Parameters

* required parameters
Parameter Description
Content-Type * application/json
X-Apikey * Your API key (This can be found in the API Settings page after logging in.)

Example value: 123456789abc1011

Body Parameters

* required parameters
Parameter Description
name * The type of SNS service. Valid value is facebook, twitter, or facebook_page. The service is case-insensitive.

Note: facebook_page_id is required if the service is "facebook_page".
description * A number value. ^[1-9][0-9]{0,17}$

This is the unique ID created by Facebook. You can find this ID within the Facebook page's Info page.

Code sample for PUT SNS Account

"Request Example: Register a Facebook or Twitter account.
PUT http://api.trumpia.com/rest/v1/{user_name}/account/sns"
{
  "service" : "facebook"
}

"Response Example:"
{
  "request_id" : "1234561234567asdf123",
  "authentication_url" : "https://www.facebook.com/oauth?get_info.php"
}

"Request Example: Register a Facebook page.
PUT http://api.trumpia.com/rest/v1/{user_name}/account/sns"
{
  "service" : "facebook_page",
  "facebook_page_id" : "456456456000"
}

"Response Example:"
{
  "request_id" : "1234561234567asdf123",
  "authentication_url" : "https://www.facebook.com/oauth?get_info.php"
}


<?
    // PUT SNS Account - Register a Facebook or Twitter account.
    include "request_rest.php";

    $request_url = "http://api.trumpia.com/rest/v1/{user_name}/account/sns";

    $request_data = array(
        "service" => "twitter"
    );

    $request_rest = new RestRequest();

    $request_rest->setRequestURL($request_url);
    $request_rest->setAPIKey("{api_key}");
    $request_rest->setRequestBody(json_encode($request_data));
    $request_rest->setMethod("PUT");
    $result = $request_rest->execute();

    $response_status = $result[0];
    $json_response_data = $result[1];

    if ($response_status == "200") {	//success
        $response_data = json_decode($json_response_data);

        echo "request_id : " . $response_data->request_id . "<br>";
        echo "service : " . $response_data->service . "<br>";
        echo "sns_id : " . $response_data->sns_id . "<br>";
        echo "status : " . $response_data->status;
    } else {
        echo $response_status ." - connection failure";
    }
?>


<?
    // PUT SNS Account - Register a Facebook page.
    include "request_rest.php";

    $request_url = "http://api.trumpia.com/rest/v1/{user_name}/account/sns";

    $request_data = array(
        "service" => "facebook_page",
        "facebook_page_id" => "456456456000"
    );

    $request_rest = new RestRequest();

    $request_rest->setRequestURL($request_url);
    $request_rest->setAPIKey("{api_key}");
    $request_rest->setRequestBody(json_encode($request_data));
    $request_rest->setMethod("PUT");
    $result = $request_rest->execute();

    $response_status = $result[0];
    $json_response_data = $result[1];

    if ($response_status == "200") {	//success
        $response_data = json_decode($json_response_data);
        echo "request_id : " . $response_data->request_id . "<br>";
        echo "service : " . $response_data->service . "<br>";
        echo "page_id : " . $response_data->sns_id . "<br>";
        echo "status : " . $response_data->status;
    } else {
        echo $response_status ." - connection failure";
    }
?>


// PUT SNS Account - Register a Facebook or Twitter account.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>SNS Account PUT Sample Code</title>
<body>

<%
	String service = "twitter";

	JSONObject snsAccountPut = new JSONObject();
	snsAccountPut.put("service", service);

	String username = "username";
	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/account/sns";
	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestMethod("PUT");
	conn.setDoOutput(true);
	conn.setDoInput(true);
	conn.setUseCaches(false);
	conn.setAllowUserInteraction(false);
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");
	OutputStream outPutStream = conn.getOutputStream();
	Writer writer = new OutputStreamWriter(outPutStream, "UTF-8");
	writer.write(snsAccountPut.toJSONString());
	writer.close();
	outPutStream.close();

	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>
	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// PUT SNS Account - Register a Facebook page.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>Facebook Page PUT Sample Code</title>
<body>

<%
	String service = "facebook_page";
	String pageId = "456456456000";

	JSONObject snsAccountPut = new JSONObject();
	snsAccountPut.put("service", service);
	snsAccountPut.put("facebook_page_id", pageId);

	String username = "username";
	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/account/sns";
	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestMethod("PUT");
	conn.setDoOutput(true);
	conn.setDoInput(true);
	conn.setUseCaches(false);
	conn.setAllowUserInteraction(false);
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");
	OutputStream outPutStream = conn.getOutputStream();
	Writer writer = new OutputStreamWriter(outPutStream, "UTF-8");
	writer.write(snsAccountPut.toJSONString());
	writer.close();
	outPutStream.close();

	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>

	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// PUT SNS Account - Register a Facebook or Twitter account.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class SnsAccountInfo
    {
        public string service { get; set; }
    }
    class Result
    {
        public string request_id { get; set; }
        public string authentication_url { get; set; }
    }
    class SnsPut
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";

                //PUT
                var info = new SnsAccountInfo() { service = "facebook" };
                Uri postUrl = new Uri(string.Format("http://api.trumpia.com/rest/v1/{0}/account/sns", username));
                var response = client.PutAsJsonAsync(postUrl, info).Result;
                if (response.IsSuccessStatusCode)
                {
                    var p = response.Content.ReadAsAsync<Result>().Result;
                    string json = JsonConvert.SerializeObject(p);
                    Console.WriteLine(json);
                }
            }
        }
    }
}


// PUT SNS Account - Register a Facebook page.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class SnsPageAccountInfo
    {
        public string service { get; set; }
        public string facebook_page_id { get; set; }
    }
    class Result
    {
        public string request_id { get; set; }
        public string authentication_url { get; set; }
    }
    class SnsPagePut
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";

                //PUT
                var info = new SnsPageAccountInfo() { service = "facebook_page", facebook_page_id = "456456456000" };
                Uri postUrl = new Uri(string.Format("http://api.trumpia.com/rest/v1/{0}/account/sns", username));
                var response = client.PutAsJsonAsync(postUrl, info).Result;
                if (response.IsSuccessStatusCode)
                {
                    var p = response.Content.ReadAsAsync<Result>().Result;
                    string json = JsonConvert.SerializeObject(p);
                    Console.WriteLine(json);
                }
            }
        }
    }
}

GET SNS Account

Lookup basic information(SNS IDs and names of existing Facebook accounts, Facebook pages, or Twitter accounts), or lookup detailed information of a specific account and page.

Resource Information

Response Formats JSON
Allowed Methods GET
URL http://api.trumpia.com/rest/v1/{user_name}/account/sns
http://api.trumpia.com/rest/v1/{user_name}/account/sns/{sns_id}
http://api.trumpia.com/rest/v1/{user_name}/account/sns/{sns_id}/page
http://api.trumpia.com/rest/v1/{user_name}/account/sns/{sns_id}/page/{page_id}
{user_name} Your account username (this can be found in the Account Settings page after logging in.)
{sns_id} Retrieve information for this SNS ID.
{page_id} Retrieve information for this Facebook Page ID.

Header Parameters

* required parameters
Parameter Description
Content-Type * application/json
X-Apikey * Your API key (This can be found in the API Settings page after logging in.)

Example value: 123456789abc1011

Code Sample for GET SNS Account

"Request Example: Get all lists of Facebook accounts, Facebook pages, and Twitter accounts.
GET http://api.trumpia.com/rest/v1/{user_name}/account/sns"

"Response Example:"
{
  "facebook_id_list" :
  [
    "987987987980", "987987987981"
  ],
  "twitter_id_list" :
  [
    "987987987982", "987987987983", "987987987984", "987987987985"
  ]
}

"Request Example: Get a specific Facebook or Twitter account.
GET http://api.trumpia.com/rest/v1/{user_name}/account/sns/{sns_id}"

"Response Example:"
{
  "service" : "facebook",
  "sns_name" : "fb.account01"
}

"Request Example: Get a Facebook page or set of pages associated with a specific Facebook account.
GET http://api.trumpia.com/rest/v1/{user_name}/account/sns/{sns_id}/page"

"Response Example:"
{
  "facebook_page_id_list" :
  [
    "456456456000", "456456456001", "456456456002", "456456456003"
  ]
}

"Request Example: Get a specific Facebook page.
GET http://api.trumpia.com/rest/v1/{user_name}/account/sns/{sns_id}/page/{page_id}"

"Response Example:"
{
  "service" : "facebook_page",
  "page_name" : "fb.account01",
  "facebook_id" : "987987987980"
}


<?
    // GET SNS Account - Retrieve all Facebook and Twitter account.
    include "request_rest.php";

    $request_url = "http://api.trumpia.com/rest/v1/{user_name}/account/sns";

    $request_rest = new RestRequest();

    $request_rest->setRequestURL($request_url);
    $request_rest->setAPIKey("{api_key}");
    $request_rest->setMethod("GET");
    $result = $request_rest->execute();

    $response_status = $result[0];
    $json_response_data = $result[1];

    if ($response_status == "200") {    //success
        echo $json_response_data;
    } else {
        echo $response_status ." - connection failure";
    }
?>



<?
    // GET SNS Account - Retrieve a Facebook or Twitter account by ID.
    include "request_rest.php";

    $request_url = "http://api.trumpia.com/rest/v1/{user_name}/account/sns";
    $sns_id = "987987987980";
    $request_url =  $request_url . "/" . $sns_id;

    $request_rest = new RestRequest();

    $request_rest->setRequestURL($request_url);
    $request_rest->setAPIKey("{api_key}");
    $request_rest->setMethod("GET");
    $result = $request_rest->execute();

    $response_status = $result[0];
    $json_response_data = $result[1];

    if ($response_status == "200") {    //success
        echo $json_response_data;
    } else {
        echo $response_status ." - connection failure";
    }
?>


<?
    // GET SNS Account - Retrieve all Facebook pages.
    include "request_rest.php";

    $request_url = "http://api.trumpia.com/rest/v1/{user_name}/account/sns";
    $sns_id = "987987987980";
    $request_url =  $request_url . "/" . $sns_id. "/page";

    $request_rest = new RestRequest();

    $request_rest->setRequestURL($request_url);
    $request_rest->setAPIKey("{api_key}");
    $request_rest->setMethod("GET");
    $result = $request_rest->execute();

    $response_status = $result[0];
    $json_response_data = $result[1];

    if ($response_status == "200") {    //success
        echo $json_response_data;
    } else {
        echo $response_status ." - connection failure";
    }
?>



<?
    // GET SNS Account - Retrieve a Facebook page by ID.
    include "request_rest.php";

    $request_url = "http://api.trumpia.com/rest/v1/{user_name}/account/sns";
    $sns_id = "987987987980";
    $page_id = "456456456000";
    $request_url =  $request_url . "/" . $sns_id. "/page/" . $page_id;

    $request_rest = new RestRequest();

    $request_rest->setRequestURL($request_url);
    $request_rest->setAPIKey("{api_key}");
    $request_rest->setMethod("GET");
    $result = $request_rest->execute();

    $response_status = $result[0];
    $json_response_data = $result[1];

    if ($response_status == "200") {    //success
        echo $json_response_data;
    } else {
        echo $response_status ." - connection failure";
    }
?>


// GET SNS Account - Retrieve all Facebook and Twitter account.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>SNS Account GET Sample Code</title>
<body>

<%
    String username = "username";
    String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/account/sns";

    URL url = new URL(urlStr);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestProperty("Content-type", "application/json");
    conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");

    if (conn.getResponseCode() != 200) {
%>
    Error : <%=conn.getResponseMessage()%>
<%
    }else{
    // Buffer the result into a string
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    StringBuilder sb = new StringBuilder();
    String line;
    while ((line = rd.readLine()) != null) {
        sb.append(line);
    }
    rd.close();
    conn.disconnect();
%>
    Response : <%=sb.toString()%>
<%
    }
%>
</body>
</html>


// GET SNS Account - Retrieve a Facebook or Twitter account by ID.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>SNS Account GET (by ID) Sample Code</title>
<body>

<%
    String username = "username";
    String snsId = "987987987980";
    String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/account/sns/" + snsId;

    URL url = new URL(urlStr);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestProperty("Content-type", "application/json");
    conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");

    if (conn.getResponseCode() != 200) {
%>
    Error : <%=conn.getResponseMessage()%>
<%
    }else{
    // Buffer the result into a string
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    StringBuilder sb = new StringBuilder();
    String line;
    while ((line = rd.readLine()) != null) {
        sb.append(line);
    }
    rd.close();
    conn.disconnect();
%>
    Response : <%=sb.toString()%>
<%
    }
%>
</body>
</html>


// GET SNS Account - Retrieve all Facebook pages.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>Facebook Page GET Sample Code</title>
<body>

<%
    String username = "username";
    String snsId = "987987987980";
    String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/account/sns/" + snsId + "/page";

    URL url = new URL(urlStr);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestProperty("Content-type", "application/json");
    conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");

    if (conn.getResponseCode() != 200) {
%>
    Error : <%=conn.getResponseMessage()%>
<%
    }else{
    // Buffer the result into a string
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    StringBuilder sb = new StringBuilder();
    String line;
    while ((line = rd.readLine()) != null) {
        sb.append(line);
    }
    rd.close();
    conn.disconnect();
%>
    Response : <%=sb.toString()%>
<%
    }
%>
</body>
</html>


// GET SNS Account - Retrieve a Facebook page by ID.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>Facebook Page GET (by ID) Sample Code</title>
<body>

<%
    String username = "username";
    String snsId = "987987987980";
    String pageId = "456456456000";
    String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/account/sns/" + snsId + "/page/" + pageId;

    URL url = new URL(urlStr);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestProperty("Content-type", "application/json");
    conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");

    if (conn.getResponseCode() != 200) {
%>
    Error : <%=conn.getResponseMessage()%>
<%
    }else{
    // Buffer the result into a string
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    StringBuilder sb = new StringBuilder();
    String line;
    while ((line = rd.readLine()) != null) {
        sb.append(line);
    }
    rd.close();
    conn.disconnect();
%>
    Response : <%=sb.toString()%>
<%
    }
%>
</body>
</html>


// GET SNS Account - Retrieve all Facebook and Twitter account.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class SnsAccountInfo
    {
        public JArray twitter_id_list { get; set; }
        public JArray facebook_id_list { get; set; }
    }
    class SnsGet
    {
        static void Main(string[] args)
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.BaseAddress = new Uri("http://api.trumpia.com");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";

                //GET
                HttpResponseMessage response = await client.GetAsync(string.Format("/rest/v1/{0}/account/sns", username));
                if (response.IsSuccessStatusCode)
                {
                    SnsAccountInfo snsInfo = await response.Content.ReadAsAsync<SnsAccountInfo>();
                    string json = JsonConvert.SerializeObject(snsInfo);
                    Console.WriteLine(json);
                }
            }
        }
    }
}

// GET SNS Account - Retrieve a Facebook or Twitter account by ID.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class SnsDetailInfo
    {
        public string sns_name { get; set; }
        public string service { get; set; }
    }
    class SnsDetailGet
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.BaseAddress = new Uri("http://api.trumpia.com");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";
                var snsId = "987987987980";

                //GET
                HttpResponseMessage response = await client.GetAsync(string.Format("/rest/v1/{0}/account/sns/{1}", username, snsId));
                if (response.IsSuccessStatusCode)
                {
                    SnsDetailInfo snsInfo = await response.Content.ReadAsAsync<SnsDetailInfo>();
                    string json = JsonConvert.SerializeObject(snsInfo);
                    Console.WriteLine(json);
                }
            }
        }
    }
}

// GET SNS Account - Retrieve all Facebook pages.
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class SnsPageAccountInfo
    {
        public JArray facebook_page_id_list { get; set; }
    }
    class SnsPageGet
    {
        static void Main(string[] args)
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.BaseAddress = new Uri("http://api.trumpia.com");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";
                var snsId = "987987987980";

                //GET
                HttpResponseMessage response = await client.GetAsync(string.Format("/rest/v1/{0}/account/sns/{1}/page", username, snsId));
                if (response.IsSuccessStatusCode)
                {
                    SnsPageAccountInfo snsPageInfo = await response.Content.ReadAsAsync<SnsPageAccountInfo>();
                    string json = JsonConvert.SerializeObject(snsPageInfo);
                    Console.WriteLine(json);
                }
            }
        }
    }
}

// GET SNS Account - Retrieve a Facebook page by ID.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class SnsPageDetailInfo
    {
        public string service { get; set; }
        public string page_name { get; set; }
        public string facebook_id { get; set; }
    }
    class SnsPageDetailGet
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.BaseAddress = new Uri("http://api.trumpia.com");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";
                var snsId = "987987987980";
                var pageId = "456456456000";

                //GET
                HttpResponseMessage response = await client.GetAsync(string.Format("/rest/v1/{0}/account/sns/{1}/page/{2}", username, snsId, pageId));
                if (response.IsSuccessStatusCode)
                {
                    SnsPageDetailInfo snsPageInfo = await response.Content.ReadAsAsync<SnsPageDetailInfo>();
                    string json = JsonConvert.SerializeObject(snsPageInfo);
                    Console.WriteLine(json);
                }
            }
        }
    }
}

DELETE SNS Account

Permanently remove a Facebook account, Facebook page, or Twitter page.

Resource Information

Response Formats JSON
Allowed Methods DELETE
URL http://api.trumpia.com/rest/v1/{username}/account/sns/{sns_id}
http://api.trumpia.com/rest/v1/{username}/account/sns/{sns_id}/page/{page_id}
{user_name} Your account username (this can be found in the Account Settings page after logging in.)
{sns_id} Delete information for this SNS ID.
{page_id} Delete information for this Facebook Page ID.

Header Parameters

* required parameters
Parameter Description
Content-Type * application/json
X-Apikey * Your API key (This can be found in the API Settings page after logging in.)

Example value: 123456789abc1011

Code sample for DELETE SNS ACCOUNT


"Request Example: Delete a specific Facebook or Twitter account.
DELETE http://api.trumpia.com/rest/v1/{user_name}/account/sns/{sns_id}"

"Request Example: Delete a specific Facebook page.
DELETE http://api.trumpia.com/rest/v1/{user_name}/account/sns/{sns_id}/page/{page_id}"

"Response Example:"
{
  "request_id" : "1234561234567asdf123"
}


<?
    // DELETE SNS Account - Delete a Facebook or Twitter account.
    include "request_rest.php";

    $request_url = "http://api.trumpia.com/rest/v1/{user_name}/account/sns";
    $sns_id = "987987987980";
    $request_url =	$request_url . "/" . $sns_id;

    $request_rest = new RestRequest();

    $request_rest->setRequestURL($request_url);
    $request_rest->setAPIKey("{api_key}");
    $request_rest->setMethod("DELETE");
    $result = $request_rest->execute();

    $response_status = $result[0];
    $json_response_data = $result[1];

    if ($response_status == "200") {	//success
        echo $json_response_data;
    } else {
        echo $response_status ." - connection failure";
    }
?>


<?
    // DELETE SNS Account - Delete a Facebook page.
    include "request_rest.php";

    $request_url = "http://api.trumpia.com/rest/v1/{user_name}/account/sns";
    $sns_id = "987987987980";
    $page_id = "456456456000";
    $request_url =	$request_url . "/" . $sns_id. "/page/" . $page_id;

    $request_rest = new RestRequest();

    $request_rest->setRequestURL($request_url);
    $request_rest->setAPIKey("{api_key}");
    $request_rest->setMethod("DELETE");
    $result = $request_rest->execute();

    $response_status = $result[0];
    $json_response_data = $result[1];

    if ($response_status == "200") {	//success
        echo $json_response_data;
    } else {
        echo $response_status ." - connection failure";
    }
?>


// DELETE SNS Account - Delete a Facebook or Twitter account.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>SNS Account DELETE Sample Code</title>
<body>

<%
	String username = "username";
	String snsId = "987987987980";
	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/account/sns/" + snsId;

	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestMethod("DELETE");
	conn.setDoOutput(true);
	conn.setAllowUserInteraction(false);
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");

	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>
	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// DELETE SNS Account - Delete a Facebook page.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.json.simple.JSONArray" %>
<%@ page import="org.json.simple.JSONObject" %>
<%@ page import="java.io.BufferedReader" %>
<%@ page import="java.io.IOException" %>
<%@ page import="java.io.InputStreamReader" %>
<%@ page import="java.io.OutputStream" %>
<%@ page import="java.io.OutputStreamWriter" %>
<%@ page import="java.io.Writer" %>
<%@ page import="java.net.HttpURLConnection" %>
<%@ page import="java.net.URL" %>
<html>
<title>Facebook Page DELETE Sample Code</title>
<body>

<%
	String username = "username";
	String snsId = "987987987980";
	String pageId = "456456456000";
	String urlStr = "http://api.trumpia.com/rest/v1/" + username + "/account/sns/" + snsId + "/page/" + pageId;

	URL url = new URL(urlStr);
	HttpURLConnection conn = (HttpURLConnection) url.openConnection();
	conn.setRequestMethod("DELETE");
	conn.setDoOutput(true);
	conn.setAllowUserInteraction(false);
	conn.setRequestProperty("Content-type", "application/json");
	conn.setRequestProperty("X-Apikey", "12345aaaaa67890aaaaa");

	if (conn.getResponseCode() != 200) {
%>
	Error : <%=conn.getResponseMessage()%>
<%
	}else{
	// Buffer the result into a string
	BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
	StringBuilder sb = new StringBuilder();
	String line;
	while ((line = rd.readLine()) != null) {
		sb.append(line);
	}
	rd.close();
	conn.disconnect();
%>
	Response : <%=sb.toString()%>
<%
	}
%>
</body>
</html>


// DELETE SNS Account - Delete a Facebook or Twitter account.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class Result
    {
        public string request_id { get; set; }
    }
    class SnsDelete
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";
                var snsId = "987987987980";
                //DELETE
                Uri deleteUrl = new Uri(string.Format("http://api.trumpia.com/rest/v1/{0}/account/sns/{1}", username, snsId));
                var response = client.DeleteAsync(deleteUrl).Result;
                if (response.IsSuccessStatusCode)
                {
                    var p = response.Content.ReadAsAsync<Result>().Result;
                    string json = JsonConvert.SerializeObject(p);
                    Console.WriteLine(json);
                }
            }
        }
    }
}


// DELETE SNS Account - Delete a Facebook page.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

namespace samplecode
{
    class Result
    {
        public string request_id { get; set; }
    }
    class SnsPageDelete
    {
        static void Main()
        {
            RunAsync().Wait();
        }

        static async Task RunAsync()
        {
            using (var client = new HttpClient())
            {
                var apikey = "12345aaaaa67890aaaaa";

                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Add("X-Apikey", string.Format("{0}", apikey));

                var username = "username";
                var snsId = "987987987980";
                var pageId = "456456456000";
                //DELETE
                Uri deleteUrl = new Uri(string.Format("http://api.trumpia.com/rest/v1/{0}/account/sns/{1}/page/{2}", username, snsId, pageId));
                var response = client.DeleteAsync(deleteUrl).Result;
                if (response.IsSuccessStatusCode)
                {
                    var p = response.Content.ReadAsAsync<Result>().Result;
                    string json = JsonConvert.SerializeObject(p);
                    Console.WriteLine(json);
                }
            }
        }
    }
}