public JPushResult Push(JPushContent content, int receiverType, List <string> receiverValue, int messageType, string platform, int sendId, int?timeToLive, string overrideId) { JPushResult result = null; if (string.IsNullOrWhiteSpace(this._appKey) || string.IsNullOrWhiteSpace(this._masterSecret) || General.IsNullable(receiverValue) || content == null) { result = new JPushResult(); result.Code = 500; result.Message = "关键参数不能为空"; return(result); } string receiver = string.Join(",", receiverValue); StringBuilder query = new StringBuilder(); query.AppendFormat( "sendno={0}&app_key={1}&receiver_type={2}", sendId, this._appKey, receiverType ); if (receiverType != JPushReceiverType.All) { query.AppendFormat("&receiver_value={0}", receiver); } query.AppendFormat( "&verification_code={0}&msg_type={1}&msg_content={2}&platform={3}", GetVerificationCode(sendId, receiverType, receiver), messageType, JsonConvert.SerializeObject(content), platform ); if (!string.IsNullOrWhiteSpace(this._sendDescription)) { query.AppendFormat("&send_description={0}", this._sendDescription); } if (timeToLive.HasValue) { query.AppendFormat("&time_to_live={0}", timeToLive); } if (!string.IsNullOrWhiteSpace(overrideId)) { query.AppendFormat("&override_msg_id={0}", overrideId); } result = JPushResult.Parse( Submit(this._host, query.ToString()) ); return(result); }
public static JPushResult Parse(string resultString) { JPushResult result = null; try { result = JsonConvert.DeserializeObject<JPushResult>(resultString); } catch (Exception ex) { result = new JPushResult(); result.Code = 500; result.Message = ex.Message; } return result; }
public static JPushResult Parse(string resultString) { JPushResult result = null; try { result = JsonConvert.DeserializeObject <JPushResult>(resultString); } catch (Exception ex) { result = new JPushResult(); result.Code = 500; result.Message = ex.Message; } return(result); }
public JPushResult Push(JPushContent content, int receiverType, List<string> receiverValue, int messageType, string platform, int sendId, int? timeToLive, string overrideId) { JPushResult result = null; if (string.IsNullOrWhiteSpace(this._appKey) || string.IsNullOrWhiteSpace(this._masterSecret) || General.IsNullable(receiverValue) || content == null) { result = new JPushResult(); result.Code = 500; result.Message = "关键参数不能为空"; return result; } string receiver = string.Join(",", receiverValue); StringBuilder query = new StringBuilder(); query.AppendFormat( "sendno={0}&app_key={1}&receiver_type={2}", sendId, this._appKey, receiverType ); if (receiverType != JPushReceiverType.All) query.AppendFormat("&receiver_value={0}", receiver); query.AppendFormat( "&verification_code={0}&msg_type={1}&msg_content={2}&platform={3}", GetVerificationCode(sendId, receiverType, receiver), messageType, JsonConvert.SerializeObject(content), platform ); if (!string.IsNullOrWhiteSpace(this._sendDescription)) query.AppendFormat("&send_description={0}", this._sendDescription); if (timeToLive.HasValue) query.AppendFormat("&time_to_live={0}", timeToLive); if (!string.IsNullOrWhiteSpace(overrideId)) query.AppendFormat("&override_msg_id={0}", overrideId); result = JPushResult.Parse( Submit(this._host, query.ToString()) ); return result; }