新增百度广告回传
This commit is contained in:
+35
-1
@@ -1,6 +1,15 @@
|
|||||||
package com.fangjia.coresite.controllers;
|
package com.fangjia.coresite.controllers;
|
||||||
|
|
||||||
|
import com.fangjia.core.util.HttpRequest;
|
||||||
|
import com.fangjia.core.util.HttpRequestException;
|
||||||
import com.fangjia.coresite.model.FangjiaModel;
|
import com.fangjia.coresite.model.FangjiaModel;
|
||||||
|
import net.sf.json.JSONArray;
|
||||||
|
import net.sf.json.JSONObject;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解决方案 控制器
|
* 解决方案 控制器
|
||||||
@@ -14,7 +23,32 @@ public class SolutionController {
|
|||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Object apiAction(FangjiaModel model) {
|
public Object apiAction(FangjiaModel model, HttpServletRequest request) {
|
||||||
|
// 对于百度广告过来的信息,进行回传
|
||||||
|
try {
|
||||||
|
String queryString = request.getQueryString();
|
||||||
|
if (StringUtils.isNotBlank(queryString) && queryString.contains("bd_vid")) {
|
||||||
|
HttpRequest httpRequest = new HttpRequest();
|
||||||
|
final String baiduUrl = "https://ocpc.baidu.com/ocpcapi/api/uploadConvertData";
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
headers.put("Content-Type", "application/json; charset=utf-8");
|
||||||
|
|
||||||
|
JSONObject requestBody = new JSONObject();
|
||||||
|
// https://fengchao.baidu.com/fc/toolscenter/optimize/track/user/27002539
|
||||||
|
requestBody.put("token", "EZGISwlOClRMEZErT2ThZTEjpLAzs2wE@9POwrGLqpRtQeGhvvCug1N3OK1tq3skk");
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
JSONObject contentJson = new JSONObject();
|
||||||
|
contentJson.put("logidUrl", request.getRequestURL().append("?" + request.getQueryString()).toString());
|
||||||
|
contentJson.put("newType", "1");
|
||||||
|
jsonArray.add(contentJson);
|
||||||
|
requestBody.put("conversionTypes", jsonArray);
|
||||||
|
String result = httpRequest.postWithBody(baiduUrl, requestBody, headers, "UTF-8");
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
} catch (HttpRequestException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user