public bool AddaPicture(ref GlobusHttpHelper HttpHelper, string Username, string Password, List<string> localImagePath, string proxyAddress, string proxyPort, string proxyUsername, string proxyPassword, string targeturl, string message, ref string status, string pageSource_Home, string xhpc_targetid, string xhpc_composerid, string message_text, string fb_dtsg, string UsreId, string pageSource, ref int tempCountMain)        
		{


			int tempCount = 0;
			startAgain:

			bool isSentPicMessage = false;
		
			string photo_id = string.Empty;


			try
			{
			

				string composer_session_id = "";

				string tempresponse1 = "";
				///temp post
				{
					string source = "";
					string profile_id = "";
					string gridID = "";
					//  string qn = string.Empty;

					try
					{
						string Url = "https://www.facebook.com/ajax/composerx/attachment/media/upload/?composerurihash=1";
						string posturl1 = "fb_dtsg=" + fb_dtsg + "&composerid=" + xhpc_composerid + "&targetid=" + xhpc_targetid + "&loaded_components[0]=maininput&loaded_components[1]=cameraicon&loaded_components[2]=withtaggericon&loaded_components[3]=placetaggericon&loaded_components[4]=mainprivacywidget&loaded_components[5]=cameraicon&loaded_components[6]=mainprivacywidget&loaded_components[7]=withtaggericon&loaded_components[8]=placetaggericon&loaded_components[9]=maininput&nctr[_mod]=pagelet_group_composer&__user="******"&__a=1&__dyn=7n88QoAMNoBwXAw&__req=i&phstamp=16581688688747595501";    //"fb_dtsg=" + fb_dtsg + "&composerid=" + xhpc_composerid + "&targetid=" + xhpc_targetid + "&istimeline=1&timelinelocation=composer&loaded_components[0]=maininput&loaded_components[1]=mainprivacywidget&loaded_components[2]=mainprivacywidget&loaded_components[3]=maininput&loaded_components[4]=explicitplaceinput&loaded_components[5]=hiddenplaceinput&loaded_components[6]=placenameinput&loaded_components[7]=hiddensessionid&loaded_components[8]=withtagger&loaded_components[9]=backdatepicker&loaded_components[10]=placetagger&loaded_components[11]=withtaggericon&loaded_components[12]=backdateicon&loaded_components[13]=citysharericon&nctr[_mod]=pagelet_timeline_recent&__user="******"&__a=1&__dyn=7n88QoAMNoBwXAw&__req=18&phstamp=1658168111112559866679";
						// string PostUrl = "city_id=" + CityIDS1 + "&city_page_id=" + city_page_id + "&city_name=" + CityName1 + "&is_default=false&session_id=1362404125&__user="******"&__a=1&__dyn=798aD5z5ynU&__req=z&fb_dtsg=" + fb_dtsg + "&phstamp=1658168111112559866165";
						string res11 = HttpHelper.postFormData(new Uri(Url), posturl1);


						try
						{
							source = res11.Substring(res11.IndexOf("source\":"), (res11.IndexOf(",", res11.IndexOf("source\":")) - res11.IndexOf("source\":"))).Replace("source\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();

						}
						catch (Exception ex)
						{
							Console.WriteLine(ex.StackTrace);
						}
						if (string.IsNullOrEmpty(source))
						{
							source = GlobusHttpHelper.getBetween(res11, "source", "profile_id").Replace("\\\"","").Replace(",","").Replace(":","").Trim();

						}
						try
						{
							profile_id = res11.Substring(res11.IndexOf("profile_id\":"), (res11.IndexOf("}", res11.IndexOf("profile_id\":")) - res11.IndexOf("profile_id\":"))).Replace("profile_id\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
							if (profile_id.Contains(","))
							{
								profile_id = ParseEncodedJson(res11, "profile_id");
							}
							//"gridID":
						}
						catch (Exception ex)
						{
							Console.WriteLine(ex.StackTrace);
						}
						if (string.IsNullOrEmpty(profile_id))
						{
							profile_id = GlobusHttpHelper.getBetween(res11, "profile_id", "}").Replace("\\\"", "").Replace(",", "").Replace(":", "").Trim();
						}
						try
						{
							gridID = res11.Substring(res11.IndexOf("gridID\":"), (res11.IndexOf(",", res11.IndexOf("gridID\":")) - res11.IndexOf("gridID\":"))).Replace("gridID\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
						}
						catch (Exception ex)
						{
							Console.WriteLine(ex.StackTrace);
						}
						if (string.IsNullOrEmpty(gridID))
						{
							gridID = GlobusHttpHelper.getBetween(res11, "gridID", ",").Replace("\\\"", "").Replace(",", "").Replace(":", "").Trim(); ;
						}


						try
						{
							composer_session_id = res11.Substring(res11.IndexOf("composer_session_id\":"), (res11.IndexOf("}", res11.IndexOf("composer_session_id\":")) - res11.IndexOf("composer_session_id\":"))).Replace("composer_session_id\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();
						}
						catch (Exception ex)
						{
							Console.WriteLine(ex.StackTrace);
						}

						try
						{
							if (string.IsNullOrEmpty(composer_session_id))
							{
								composer_session_id = res11.Substring(res11.IndexOf("composerID\":"), (res11.IndexOf("}", res11.IndexOf("composerID\":")) - res11.IndexOf("composerID\":"))).Replace("composerID\":", string.Empty).Replace("<dd>", string.Empty).Replace("\\", string.Empty).Replace("\"", string.Empty).Trim();

							}
						}
						catch (Exception ex)
						{
							Console.WriteLine(ex.StackTrace);
						}

						try
						{
							qn =GlobusHttpHelper.getBetween(res11, "qn", "/>");
							qn =qn.Replace("\\\\\\\"","@");
							qn =GlobusHttpHelper.getBetween(qn, "@ value=@", "@");
						}
						catch (Exception ex)
						{
							Console.WriteLine(ex.StackTrace);
						}
					}
					catch (Exception ex)
					{
						Console.WriteLine(ex.StackTrace);
					}

					NameValueCollection nvc1 = new NameValueCollection();
					try
					{
						//message = Uri.EscapeDataString(message);
					}
					catch (Exception ex)
					{
						Console.WriteLine(ex.StackTrace);
					}

				
					nvc1.Add("fb_dtsg", fb_dtsg);
					nvc1.Add("source", source);
					nvc1.Add("profile_id", profile_id);
					nvc1.Add("grid_id", gridID);
					nvc1.Add("upload_id", "1024");
					nvc1.Add("qn", qn);


					string _rev =GlobusHttpHelper.getBetween(pageSource, "svn_rev", ",");
					_rev = _rev.Replace("\":", string.Empty);


					string uploadURL = "https://upload.facebook.com/ajax/composerx/attachment/media/saveunpublished?target_id=" + xhpc_targetid + "&__user="******"&__a=1&__dyn=7n88Oq9ccmqDxl2u5Fa8HzCqm5Aqbx2mbAKGiBAGm&__req=1t&fb_dtsg=" + fb_dtsg + "&__rev=" + _rev + "";
				   //  tempresponse1 = HttpHelper.HttpUploadFile_UploadPic_tempforsingle(ref HttpHelper, UsreId, uploadURL, "composer_unpublished_photo[]", "image/jpeg", localImagePath, nvc1, "", proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);

					if (tempresponse1.ToLower().Contains("errorsummary") && tempresponse1.ToLower().Contains("There was a problem with this request. We're working on getting it fixed as soon as we can".ToLower()))
					{
						if (tempCount < 2)
						{
							System.Threading.Thread.Sleep(15000);
							tempCount++;
							goto startAgain;
						}
						else
						{
							tempCountMain++;
							return false;
						}
					}



				}

				NameValueCollection nvc = new NameValueCollection();
				try
				{
					//message = Uri.EscapeDataString(message);
				}
				catch (Exception ex)
				{
					Console.WriteLine(ex.StackTrace);
				}
				nvc.Add("fb_dtsg", fb_dtsg);
				nvc.Add("xhpc_targetid", xhpc_targetid);
				nvc.Add("xhpc_context", "profile");
				nvc.Add("xhpc_ismeta", "1");
				nvc.Add("xhpc_fbx", "1");
				nvc.Add("xhpc_timeline", "");
				nvc.Add("xhpc_composerid", xhpc_composerid);
				nvc.Add("xhpc_message_text", message);
				nvc.Add("xhpc_message", message);
			


				string composer_unpublished_photo = "";
				try
				{
					string start_composer_unpublished_photo = Regex.Split(tempresponse1, "},\"")[1];// 



					int startIndex_composer_unpublished_photo = start_composer_unpublished_photo.IndexOf(",\"") + ",\"".Length;
					int endIndex_composer_unpublished_photo = start_composer_unpublished_photo.IndexOf("\"", startIndex_composer_unpublished_photo + 1);

					composer_unpublished_photo = start_composer_unpublished_photo.Substring(startIndex_composer_unpublished_photo, endIndex_composer_unpublished_photo - startIndex_composer_unpublished_photo);
				}
				catch (Exception ex)
				{
					Console.WriteLine(ex.StackTrace);
				}

				if (tempresponse1.Contains("composer_unpublished_photo"))
				{
					try
					{
						composer_unpublished_photo = tempresponse1.Substring(tempresponse1.IndexOf("composer_unpublished_photo[]"), tempresponse1.IndexOf("u003Cbutton") - tempresponse1.IndexOf("composer_unpublished_photo[]")).Replace("composer_unpublished_photo[]", "").Replace("value=", "").Replace("\\", "").Replace("\\", "").Replace("/>", "").Replace("\"", "").Trim();

					}
					catch (Exception ex)
					{
						Console.WriteLine(ex.StackTrace);
					}
				}
				///New test upload pic post
				string waterfallid = GlobusHttpHelper.ParseJson(pageSource_Home, "waterfallID");

				if (waterfallid.Contains("ar"))
				{
					waterfallid = qn;
				}


				string newpostURL = "https://upload.facebook.com/media/upload/photos/composer/?__user="******"&__a=1&__dyn=7n88QoAMNoBwXAw&__req=r&fb_dtsg=" + fb_dtsg + "";
				string newPostData = "";


				NameValueCollection newnvc = new NameValueCollection();
				try
				{
					//message = Uri.EscapeDataString(message);
				}
				catch (Exception ex)
				{
					Console.WriteLine(ex.StackTrace);
				}

				newnvc.Add("fb_dtsg", fb_dtsg);
				newnvc.Add("xhpc_targetid", xhpc_targetid);
				newnvc.Add("xhpc_context", "profile");
				newnvc.Add("xhpc_ismeta", "1");
				newnvc.Add("xhpc_fbx", "1");
				newnvc.Add("xhpc_timeline", "");
				newnvc.Add("xhpc_composerid", xhpc_composerid);
				newnvc.Add("xhpc_message_text", message);
				newnvc.Add("xhpc_message", message);

				newnvc.Add("composer_unpublished_photo[]", composer_unpublished_photo);
				newnvc.Add("album_type", "128");
				newnvc.Add("is_file_form", "1");
				newnvc.Add("oid", "");
				newnvc.Add("qn", waterfallid);
				newnvc.Add("application", "composer");
				newnvc.Add("is_explicit_place", "");
				newnvc.Add("composertags_place", "");
				newnvc.Add("composertags_place_name", "");
				newnvc.Add("composer_session_id", composer_session_id);
				newnvc.Add("composertags_city", "");
				newnvc.Add("vzdisable_location_sharing", "false");
				newnvc.Add("composer_predicted_city", "");



				string response =HttpHelper.HttpUploadFile_UploadPic(ref HttpHelper, UsreId, newpostURL, "file1", "image/jpeg", localImagePath, newnvc, targeturl, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);//HttpUploadFile_UploadPic(ref HttpHelper, UsreId, "http://upload.facebook.com/media/upload/photos/composer/?__user="******"&__a=1&__dyn=7n88O49ccm9o-2Ki&__req=1c&fb_dtsg=" + fb_dtsg + "", "file1", "image/jpeg", localImagePath, nvc, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);


				if (response.Contains("post this because it has a blocked link"))
				{
					try
					{
						AddToLogger_GroupManager("-------blocked link-------");
						return false;

					}
					catch (Exception ex)
					{
						Console.WriteLine(ex.StackTrace);
					}

				}

			
				if (string.IsNullOrEmpty(response))
				{
					try
					{

						response = HttpHelper.HttpUploadFile_UploadPic(ref HttpHelper, UsreId, "https://upload.facebook.com/media/upload/photos/composer/?__user="******"&__a=1&__dyn=7n88O49ccm9o-2Ki&__req=1c&fb_dtsg=" + fb_dtsg + "", "file1", "image/jpeg", localImagePath, nvc, targeturl, proxyAddress, Convert.ToInt32(0), proxyUsername, proxyPassword);
					}
					catch (Exception ex)
					{
						Console.WriteLine(ex.StackTrace);
					}
				}
				string posturl = "https://www.facebook.com/ajax/places/city_sharer_reset.php";
				string postdata = "__user="******"&__a=1&fb_dtsg=" + fb_dtsg + "&phstamp=1658167761111108210145";
				string responsestring = HttpHelper.postFormData(new Uri(posturl), postdata);
				try	
				{
					string okay = HttpHelper.getHtmlfromUrl(new Uri("https://3-pct.channel.facebook.com/pull?channel=p_" + UsreId + "&seq=3&partition=69&clientid=70e140db&cb=8p7w&idle=8&state=active&mode=stream&format=json"),"","");
				}
				catch (Exception ex)
				{
					Console.WriteLine(ex.StackTrace);
				}

				if (!string.IsNullOrEmpty(response) && response.Contains("payload\":{\"photo_fbid"))//response.Contains("photo.php?fbid="))
				{

					try
					{

						if (!response.Contains("errorSummary") || !response.Contains("error"))
						{
							isSentPicMessage = true;
						}
						if (response.Contains("Your post has been submitted and is pending approval by an admin"))
						{
							Console.WriteLine("Your post has been submitted and is pending approval by an admin." + "GroupUrl >>>" + targeturl);

						}
					}
					catch (Exception ex)
					{
						Console.WriteLine(ex.StackTrace);
					}				

				}

			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.StackTrace);
			}
			return isSentPicMessage;

		}