首页 > Java

Java调用优酷接口例子

发表于2015-05-11 11:01:12| --次阅读| 来源webkfa| 作者Java哥

摘要:Java调用优酷接口例子

优酷sdk下载

调用代码示例

java代码
import java.io.File;
import java.util.HashMap;

import com.youku.uploader.FileUtil;
import com.youku.uploader.YoukuUploader;
/**
 * web开发技术提供
 * 网址:
 * http://www.webkfa.com
 */
   
public class Test {
	private static YoukuUploader uploader;
    public static void main(String[] args) {
    	String client_id = ""; //OpenAPI client_id
		String client_secret = ""; //OpenAPI client_secret
		String username = ""; //Youku username or email
		String password = ""; //youku password
		String result = "";
		String access_token = ""; 
		HashMap<String, String> params, uploadInfo;
		String filename = "";
		File uploadFile = new File(filename);
		byte[] data = FileUtil.getBytesFromFile(uploadFile); // 待上传文件字节数组
		params = new HashMap<String, String>();
		params.put("username", username);
		params.put("password", password);
		params.put("access_token", access_token);
		uploadInfo = new HashMap<String, String>();
		uploadInfo.put("file_name", filename); // 指定:文件名
		uploadInfo.put("title", ""); // 指定:标题
		uploadInfo.put("tags", ""); // 指定:分类
		uploader = new YoukuUploader(client_id, client_secret);
		result = uploader.upload(params, uploadInfo, data, false);
		System.out.print(result);
    }
} 

优酷开发平台地址

相关文章

猜你喜欢

学到老在线代码浏览器 关闭浏览
友情链接: hao123 360导航 搜狗网址导航 114啦网址导航 博客大全
Copyright © 1999-2014, WEBKFA.COM, All Rights Reserved  京ICP备14034497号-1