[Android] Posting using Kakao Story custom scheme


Writing time : 2016-04-13 01:41:46

Posting using Kakao Story custom scheme

Post Kakao Story


If you have the Kakao Story app installed, you can post articles using a custom scheme without using the Kakao SDK.

For how to post using a custom scheme, refer to the sample source below.

String shareBody = "http://www.goooood.netn하하하";  
String appId = getContext().getPackageName();  
String appName = "MyApp";  
String urlInfo = "{title:'테스트',desc:'카카오스토리 테스트입니다.~',imageurl:['http://goooood.net/share.png']}";  
  
String url = String.format(  
"storylink://posting?post=%s&appid=%s&appver=1.0&apiver=1.0&appname=%s&urlinfo=%s",  
shareBody, appId, appName, urlInfo);  
  
  
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));  
getActivity().startActivity(intent);  

For the value used for URL generation in the source code, refer to the parameter description in the Kakao Story Developer Guide.

Kakao Story API parameter description

The urlinfo part of the parameter is further explained as follows.

Kakao Story API urlinfo description

For more details, please refer to the Scroolink Developer Guide page.

http://www.kakao.com/services/api/story$ITALICWORDlink

When the code is executed, the post registration window of Kakao Story is displayed as shown below, and when the user clicks the "Post" button, it is shared.

Kakao Story custom scheme

URLs created from source code behave the same on the web.

If you want to publish immediately without a registration window, you must use the Kakao SDK.

Exception handling when Kakao Story is not installed


If Kakao Story is not installed, the code will not work properly, so you need to check the installation and handle exceptions.

You can check whether a specific package is installed or not by using the function below.

The package name of Kakao Story is "com.kakao.story", so passing this value as the second parameter returns whether Kakao Story is installed or not.

public static boolean isInstalledPackage(Context context, String pkgName){  
if (pkgName != null) {  
try {  
PackageManager pm = context.getPackageManager();  
pm.getInstallerPackageName(pkgName);  
return true;  
} catch (Exception e) {  
}  
}  
return false;  
}  
Previous post

Next post