洛米对接文档

1.API接入指南

1-1 API申请步骤

步骤1:在[洛米官网](http://www.luomi.com)中注册成为开发者

步骤2:创建一款应用,您将获得一个appkey,用于标识您的应用

步骤3:联系客服人员审批应用

步骤4:获取相应API的接口

2-2 获取广告API对接说明

API对接说明文档地址

2.安卓SDK接入指南

点击下载sdk对接文档

3.IOS-SDK接入指南

点击下载sdk对接文档

4.API对接下载必看

由于本平台有Https的广告链接,所有开发者实现的webview需要支持https的处理,否则可能影响计费:下面给出具体代码,如若还有问题请及时沟通

分析:在Android5.0以下,默认是采用的MIXED_CONTENT_ALWAYS_ALLOW模式,即总是允许WebView同时加载Https和Http;而从Android5.0开始,默认用MIXED_CONTENT_NEVER_ALLOW模式,即总是不允许WebView同时加载Https和Http


1、 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {  
       webView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);  
    } 

3、下载方式
	mWebView.setDownloadListener(new DownloadListener() {
		@Override
		public void onDownloadStart(final String url, String userAgent,
			String contentDisposition, String mimetype,
			long contentLength) {
			String content = "是否确定下载该游戏?";
			content = "当前是非WIFI状态,是否继续下载?";
			AlertDialog.Builder builder = new AlertDialog.Builder(
			context);
				builder.setTitle("下载提示")
					.setMessage(content)
					.setPositiveButton("确定",
						new DialogInterface.OnClickListener() {
							@Override
							public void onClick(
							DialogInterface dialog,
							int which) {
								//方式1   跳转浏览器下载
								Intent intent= new Intent();        
								intent.setAction("android.intent.action.VIEW");    
								Uri content_url = Uri.parse(url);   
								intent.setData(content_url);  
								startActivity(intent);
								//方式2  用安卓原生的DownLoadmanager下载   具体参考第6项
								//方式3  自行实现下载逻辑
							}
						})
						.setNegativeButton("取消",
							new DialogInterface.OnClickListener() {
								@Override
								public void onClick(
									DialogInterface dialog,
									int which) {

								}
						});
				dialog = builder.create();
				if (context.hasWindowFocus()) {
					dialog.show();
				}
			}

	});

4、由于广告链接涉及到下载功能,如果开发者的targetSDK>=23需要动态申请文件读写权限,另外安装时加入targetSDK>=25需要加权限
	<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

5、安卓7.0版本适配安装
<provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="包名.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">

            <!-- 元数据 -->
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"/>
    </provider>

6、DownloadManager下载伪代码
public class MainActivity extends AppCompatActivity {
		private DownloadUtils downloadUtils;
		@Override
		protected void onCreate(Bundle savedInstanceState) {
			super.onCreate(savedInstanceState);
			setContentView(R.layout.activity_main);
			downloadUtils =   new DownloadUtils(MainActivity.this); 
			downloadUtils.downloadAPK("http://XXX.apk", "XXX.apk");

    }
	
	public class DownloadUtils {
    //下载器
    private DownloadManager downloadManager;
    //上下文
    private Context mContext;
    //下载的ID
    private long downloadId;
    public  DownloadUtils(Context context){
        this.mContext = context;
    }

    //下载apk
    public void downloadAPK(String url, String name) {

        //创建下载任务
        Request request = new Request(Uri.parse(url));
        //移动网络情况下是否允许漫游
        request.setAllowedOverRoaming(false);

        //在通知栏中显示,默认就是显示的
        request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
        request.setTitle("新版本Apk");
        request.setDescription("Apk Downloading");
        request.setVisibleInDownloadsUi(true);

        //设置下载的路径
        request.setDestinationInExternalPublicDir(Environment.getExternalStorageDirectory().getAbsolutePath() , name);

       //获取DownloadManager
        downloadManager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
        //将下载请求加入下载队列,加入下载队列后会给该任务返回一个long型的id,通过该id可以取消任务,重启任务、获取下载的文件等等
        downloadId = downloadManager.enqueue(request);

        //注册广播接收者,监听下载状态
        mContext.registerReceiver(receiver,
                new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    }

    //广播监听下载的各个状态
    private BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            checkStatus();
        }
    };


    //检查下载状态
    private void checkStatus() {
        Query query = new Query();
        //通过下载的id查找
        query.setFilterById(downloadId);
        Cursor c = downloadManager.query(query);
        if (c.moveToFirst()) {
            int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS));
            switch (status) {
                 //下载暂停
                case DownloadManager.STATUS_PAUSED:
                    break;
                //下载延迟
                case DownloadManager.STATUS_PENDING:
                    break;
                //正在下载
                case DownloadManager.STATUS_RUNNING:
                    break;
                //下载完成
                case DownloadManager.STATUS_SUCCESSFUL:
                    //下载完成安装APK
                    installAPK();
                    break;
                //下载失败
                case DownloadManager.STATUS_FAILED:
                    Toast.makeText(mContext, "下载失败", Toast.LENGTH_SHORT).show();
                    break;
            }
        }
        c.close();
    }

    //下载到本地后执行安装
    private void installAPK() {
        //获取下载文件的Uri
        Uri downloadFileUri = downloadManager.getUriForDownloadedFile(downloadId);
        if (downloadFileUri != null) {
            Intent intent= new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(downloadFileUri, "application/vnd.android.package-archive");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mContext.startActivity(intent);
            mContext.unregisterReceiver(receiver);
        }
    }

}
}

5.视频API接入指南

5-1 获取浮标图片

获取浮标图片接口示例(接口从开发者后台获取,申请步骤同普通API)

http://sdk.cferw.com/videotrans.php?z=9496&appkey=f06c62264f52ee27e74f10e027aac6de&deviceId=xxxxxxxxxxxxxxxx&sw=0&sh=0&osver=6.5&devtype=1

请求参数说明:

字段名 类型 是否必传 字段说明
z int 广告位标识,在开发者平台自动生成,直接获取即可
appkey string 应用key,唯一标识
deviceId string Android传imei,Ios传idfa
devtype string 1表示Android 2表示ios
sw string 屏幕宽
sh string 屏幕高

返回成功示例:


{
	"succ": 1,
	"code": 0,
	"data": {
		"iconurl": "http:\/\/pat.farvd.com\/uploads\/picture\/2016\/05\/16\/1526452871.gif",
		"wenzi": "您有红包未领取!",
		"icon_showurl": "https:\/\/anquan.luomi.com\/adveranaly\/redpack\/redpackjs?k={"appkey ":"f06c62264f52ee27e74f10e027aac6de ","devideid ":"xxxxxxxxxxxxxxxx ","luckpageid ":"0 ","adid ":"0 ","iconid ":"7 ","tptype ":"11 "}",
		"icon_clickurl": "https:\/\/anquan.luomi.com\/adveranaly\/redpack\/redpackjs?k={"appkey ":"f06c62264f52ee27e74f10e027aac6de ","devideid ":"xxxxxxxxxxxxxxxx ","luckpageid ":"0 ","adid ":"0 ","iconid ":"7 ","tptype ":"12 "}",
		"iconapi": "http:\/\/sdk.cferw.com\/api.php?z=9496&appkey=f06c62264f52ee27e74f10e027aac6de&deviceId=xxxxxxxxxxxxxxxx&sw=0&sh=0&osver=6.5"
	}
}
			

返回参数说明:

字段名 类型 字段说明
succ int 1表示接口返回成功的状态值,0表示有错误提示的状态值
code string 0表示没有错误的状态码
data json 包含正确信息的json对象
iconurl string 表示浮标图片地址
wenzi string 表示浮标图片上展示的文字(如有需要)
icon_showurl string 表示浮标展示时,记录展示接口
icon_clickurl string 表示浮标点击时 ,记录点击接口
iconapi string 表示获取视频广告的接口

返回错误示例:


{
	"succ": 0,
	"code": 1
}
			

返回参数说明:

字段名 类型 字段说明
succ int 0表示有错误提示的状态值
code string 1 表示appkey为空;2 表示设备id为空;3 表示广告位z值为空;4 表示浮标图片返回失败

5-3 获取视频信息

获取视频信息接口示例(该接口取自获取浮标图片接口返回的iconapi,直接调用即可)

http://sdk.cferw.com//api.php?z=9496&appkey=f06c62264f52ee27e74f10e027aac6de&deviceId=xxxxxxxxxxxxxxxx&sw=0&sh=0&osver=6.5

返回成功示例:


{
	"imgurl": "http:\/\/pat.farvd.com\/uploads\/picture\/2016\/05\/21\/1526868706.jpg",
	"imgurl2": "http:\/\/pat.farvd.com\/uploads\/picture\/2016\/05\/21\/1526868698.mp4",
	"getImageTJ": "1526868706",
	"wenzi": "《不良人2》",
	"wenzi2": "精彩绝伦,绝世创作",
	"mediaid": "876",
	"planid": "3520",
	"gotourl": "https:\/\/cdnsjzs.9377.com\/bmt\/bmt_lmaz_7.apk",
	"ip": "218.241.251.154",
	"key": "f06c62264f52ee27e74f10e027aac6de",
	"count_url": "http:\/\/api.cferw.com\/reapi.php?s=ODg1Mzg0fDEwMHw5NDk2fDMyfDg3NnwzNTIwfDIxOC4yNDEuMjUxLjE1NHx4eHh4eHh4eHh4eHh4eHh4;584cf2987942e48172914bf9470db2a8;1&getImageTJ=&key=f06c62264f52ee27e74f10e027aac6de&lrdst=MTUyNzQ5MDQyNC44NDM5",
	"click_url": "http:\/\/api.cferw.com\/reapi.php?s=ODg1Mzg0fDEwMHw5NDk2fDMyfDg3NnwzNTIwfDIxOC4yNDEuMjUxLjE1NHx4eHh4eHh4eHh4eHh4eHh4;584cf2987942e48172914bf9470db2a8;1&getImageTJ=&clicks=1&key=f06c62264f52ee27e74f10e027aac6de&lrdst=MTUyNzQ5MDQyNC44NDM5",
	"sdown_url": "https:\/\/anquan.luomi.com\/adveranaly\/downinfo\/apiDownDb?dev_appkey=f06c62264f52ee27e74f10e027aac6de&dev_time={dev_time}&dev_flag=1&dev_planid=3520&dev_deviceid=xxxxxxxxxxxxxxxx&plat=1",
	"edown_url": "https:\/\/anquan.luomi.com\/adveranaly\/downinfo\/apiDownDb?dev_appkey=f06c62264f52ee27e74f10e027aac6de&dev_time={dev_time}&dev_flag=2&dev_planid=3520&dev_deviceid=xxxxxxxxxxxxxxxx&plat=1",
	"finish_url": "https:\/\/anquan.luomi.com\/adveranaly\/instalinfo\/apiInstalDb?appkey=f06c62264f52ee27e74f10e027aac6de&deviceId=xxxxxxxxxxxxxxxx&plat=1&packageName={packageName}&dev_flag=2&dev_time={dev_time}",
	"is_link": 2,
	"succ": 1,
	"code": 0
}
			

返回参数说明(此处只对视频广告的特殊参数说明,其他参数同普通API):

字段名 类型 字段说明
imgurl string 视频第一帧图片链接地址
imgurl2 string 视频链接地址
wenzi string 视频标题
wenzi2 string 视频内容描述