本文整理汇总了C#中BaseLib.GlobusHttpHelper.HttpUploadProfilePic方法的典型用法代码示例。如果您正苦于以下问题:C# GlobusHttpHelper.HttpUploadProfilePic方法的具体用法?C# GlobusHttpHelper.HttpUploadProfilePic怎么用?C# GlobusHttpHelper.HttpUploadProfilePic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseLib.GlobusHttpHelper
的用法示例。
在下文中一共展示了GlobusHttpHelper.HttpUploadProfilePic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetProfilePic
public bool SetProfilePic(ref GlobusHttpHelper HttpHelper, string profileId, string Username, string Password, string localImagePath, string proxyAddress, string proxyPort, string proxyUsername, string proxyPassword, ref string status, string UploadInfoData)
{
string FirstGetREsponse = string.Empty;
try
{
FirstGetREsponse = HttpHelper.getHtmlfromUrl(new Uri("http://www.linkedin.com/profile/edit-picture-info?trk=prof-ovw-edit-photo"));
}
catch { }
if (string.IsNullOrEmpty(FirstGetREsponse))
{
try
{
FirstGetREsponse = HttpHelper.getHtmlfromUrl(new Uri("https://www.linkedin.com/profile/edit-picture-info?goback=%2Enpv_" + profileId + "_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1&trk=prof-ovw-edit-photo"));
}
catch { }
}
string[] upload_infoArr = Regex.Split(FirstGetREsponse, " name=\"upload_info");
string upload_infow = string.Empty;
string upload_infowithjs = string.Empty;
if (true)
{
try
{
upload_infow = upload_infoArr[1].Substring(upload_infoArr[1].IndexOf("value="), upload_infoArr[1].IndexOf(">") - upload_infoArr[1].IndexOf("value=")).Replace("value=", string.Empty).Replace("\"", string.Empty).Replace("\\", string.Empty).Replace("/", string.Empty).Trim();
}
catch { }
try
{
upload_infowithjs = upload_infoArr[2].Substring(upload_infoArr[2].IndexOf("value="), upload_infoArr[2].IndexOf(">") - upload_infoArr[2].IndexOf("value=")).Replace("value=", string.Empty).Replace("\"", string.Empty).Replace("\\", string.Empty).Replace("/", string.Empty).Trim();
}
catch { }
}
else
{
//try
//{
// string[] upload_infoArr1 = Regex.Split(FirstGetREsponse, "id\":\"upload_info");
// upload_infow = upload_infoArr1[1].Substring(upload_infoArr1[1].IndexOf("value\":"), upload_infoArr1[1].IndexOf("type") - upload_infoArr1[1].IndexOf("value\":")).Replace("value\":", string.Empty).Replace("\"", string.Empty).Replace("\\", string.Empty).Replace(",", string.Empty).Trim();
//}
//catch { }
}
string posturi = string.Empty;
if (FirstGetREsponse.Contains("name=\"uploadMemberPicture"))
{
try
{
string[] MemberPicture = Regex.Split(FirstGetREsponse, "name=\"uploadMemberPicture");
posturi = MemberPicture[1].Substring(MemberPicture[1].IndexOf("action="), MemberPicture[1].IndexOf("method=") - MemberPicture[1].IndexOf("action=")).Replace("action=", string.Empty).Replace("\"", string.Empty).Replace("\\", string.Empty).Replace("/", string.Empty).Trim();
}
catch { }
}
bool isSetProfilePic = false;
try
{
string upload_info = "";
upload_info = upload_infow;
string upload_info_with_js = "";
upload_info_with_js = upload_infowithjs;
//upload_info = upload_info.Replace("&dsh;", "-"); ;
//upload_info_with_js = upload_info;
string callback = "";
callback = "profilePicture.processResponse";
NameValueCollection nvc = new NameValueCollection();
nvc.Add("upload_info", upload_info_with_js);
nvc.Add("upload_info_with_js", upload_info_with_js);
nvc.Add("callback", callback);
//nvc.Add("Content-Type:", "image/jpeg");
posturi = posturi.Replace("mupld", string.Empty);
//string response = HttpHelper.HttpUploadProfilePic(ref HttpHelper, profileId, "http://www.linkedin.com/mupld/" + posturi, "pic", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(proxyPort), proxyUsername, proxyPassword);
string response = string.Empty;
try
{
response = HttpHelper.HttpUploadProfilePic(ref HttpHelper, profileId, "http://www.linkedin.com/mupld/upload", "pic", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(proxyPort), proxyUsername, proxyPassword);
}
catch { }
if (string.IsNullOrEmpty(response))
{
response = HttpHelper.HttpUploadProfilePic(ref HttpHelper, profileId, "https://www.linkedin.com/mupld/upload?goback=%2Enpv_" + profileId + "_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1_*1", "pic", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(proxyPort), proxyUsername, proxyPassword);
//http://www.linkedin.com/mupld/process?filter=car450&return_type=html&mid=%2Fp/6/005/025/1b7/34bf4a0.jpg&callback=profilePicture.savePhoto&filters_scale_h=397&filters_scale_w=600&filters_crop_x=101&filters_crop_y=0&filters_crop_h=396.99966&filters_crop_w=396.99966&filters_rotate_t=
}
string Images1 = string.Empty;
if (response.Contains("SUCCESS"))
{
try
{
Images1 = response.Substring(response.IndexOf("value\":"), response.IndexOf("}") - response.IndexOf("value\":")).Replace("value\":", string.Empty).Replace("\"", string.Empty).Replace("\\", string.Empty).Trim();
Images1 = Images1.Substring(1, (Images1.Length - 1));
Images1 = Images1.Remove(Images1.IndexOf(","));
Images1 = "/" + Images1;
}
catch { }
}
string csrfToken = string.Empty;
string sourceAlias = string.Empty;
//.........这里部分代码省略.........