If you think the Android project kakao-android-sdk-standalone listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/**
* Copyright 2014 Minyoung Jeong <kkungkkung@gmail.com>
* Copyright 2014 Kakao Corp.//fromwww.java2s.com
*
* Redistribution and modification in source or binary forms are not permitted without specific prior written permission.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.kakao;
import android.os.Bundle;
import com.kakao.helper.ServerProtocol;
import com.kakao.http.FilePart;
import com.kakao.http.HttpRequestBuilder;
import com.kakao.http.HttpRequestTask;
import com.kakao.rest.APIHttpRequestTask;
import java.io.File;
import java.io.FileNotFoundException;
/**
* ?????? API ????? ????.
* @author MJ
*/publicclass KakaoStoryService {
/**
* ?????? ??? ??
* @param responseHandler ??? ?? ???? ?? handler
*/publicstaticvoid requestProfile(final KakaoStoryHttpResponseHandler<KakaoStoryProfile> responseHandler) {
String url = HttpRequestTask.createBaseURL(ServerProtocol.API_AUTHORITY, ServerProtocol.STORY_PROFILE_PATH);
HttpRequestBuilder requestBuilder = HttpRequestBuilder.post(url);
APIHttpRequestTask.addCommon(requestBuilder);
APIHttpRequestTask.checkSessionAndExecute(
new APIHttpRequestTask<KakaoStoryProfile>(
requestBuilder.build(),
responseHandler,
KakaoStoryProfile.class
),
responseHandler
);
}
/**
* ???????? ????? ????? ????? ??? ??
* @param responseHandler ????? ??? ?? ???? ?? handler
* @param file ???? ????? ????
* @throws FileNotFoundException ???? ??????? ???? ?? ?? ?????.
*/publicstaticvoid requestUpload(final KakaoStoryHttpResponseHandler<KakaoStoryUpload> responseHandler, finalFile file) throws FileNotFoundException {
String url = HttpRequestTask.createBaseURL(ServerProtocol.API_AUTHORITY, ServerProtocol.STORY_UPLOAD_PATH);
HttpRequestBuilder requestBuilder = HttpRequestBuilder.post(url);
APIHttpRequestTask.addCommon(requestBuilder);
requestBuilder.setBodyEncoding(ServerProtocol.BODY_ENCODING);
requestBuilder.addBodyPart(new FilePart(ServerProtocol.FILE_KEY, file));
APIHttpRequestTask.checkSessionAndExecute(new APIHttpRequestTask<KakaoStoryUpload>(requestBuilder.build(), responseHandler, KakaoStoryUpload.class), responseHandler);
}
/**
* ???????? ????? ??
* @param responseHandler ????? ?? ???? ?? handler
* @param parameters ?????? ??? ??
*/publicstaticvoid requestPost(final KakaoStoryHttpResponseHandler<Void> responseHandler,
final Bundle parameters) {
String url = HttpRequestTask.createBaseURL(ServerProtocol.API_AUTHORITY, ServerProtocol.STORY_POST_PATH);
HttpRequestBuilder requestBuilder = HttpRequestBuilder.post(url);
APIHttpRequestTask.addCommon(requestBuilder);
APIHttpRequestTask.addQueryParams(requestBuilder, parameters);
APIHttpRequestTask.checkSessionAndExecute(new APIHttpRequestTask<Void>(requestBuilder.build(), responseHandler, Void.class), responseHandler);
}
}