Witam mam napisany taki kod :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System.Web.Script.Serialization;
using System.Diagnostics;
using HtmlAgilityPack;
namespace Fotka_Api
{
public partial class Form2 : Form
{
private Form1 formaa1;
public Form2(Form1 forma1)
{
InitializeComponent();
formaa1 = forma1;
}
private void Form2_Load(object sender, EventArgs e)
{
LinkLabel.Link link = new LinkLabel.Link();
link.LinkData = "http://www.fotka.pl/powiadomienia";
linkLabel1.Links.Add(link);
formaa1.Visible = false;
string url = "http://api.fotka.pl/v2/user/login?";
CookieContainer cookies = new CookieContainer();
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.CookieContainer = cookies;
request.Method = "GET";
WebResponse response = request.GetResponse();
response.Close();
//USER LOGIN//
request = (HttpWebRequest)HttpWebRequest.Create(url);
request.CookieContainer = cookies;
request.Method = "POST";
string login = "";
string haslo = "";
login = formaa1.textBox1.Text;
haslo = formaa1.textBox2.Text;
string postData = "login=" + login + "&password=" + haslo;
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
response = (HttpWebResponse)request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
//Parsowanie JSON -odpowiedz s serwera datastream/nowy streamreader-reader przypisanie
//datastream-JOBject pobieram Reader.
JObject oObject = JObject.Parse(reader.ReadToEnd());
string id = (string)oObject["id"]; //<<numer identyfikacyjny użytkownika:
string logins = (string)oObject["login"];
string CITY = (string)oObject["city"];
string BIRTHDAY = (string)oObject["birthDate"];
reader.Close();
dataStream.Close();
response.Close();
//User/About
string userAbout = "http://api.fotka.pl/v2/user/about?user_id=" + id;
request = (HttpWebRequest)HttpWebRequest.Create(userAbout);
request.CookieContainer = cookies;
request.Method = "GET";
response = (HttpWebResponse)request.GetResponse();
Stream aboutStream = response.GetResponseStream();
StreamReader aboutReader = new StreamReader(aboutStream);
//ZACZYNAM Parsowanie JSON///
JObject aboutObject = JObject.Parse(aboutReader.ReadToEnd());
string IMIE = (string)aboutObject["data"]["imie"];
string aboutResponse = aboutReader.ReadToEnd();
//Dane Uzytkownika//
string wzrost = (string)aboutObject["data"]["wzrost"];
//Cechy Wyglądu//
string dlugoscWlosowV = (string)aboutObject["data"]["cechy"]["wyglad"][0]["value"];
string kolorWlosowV = (string)aboutObject["data"]["cechy"]["wyglad"][1]["value"];
string kolorOczuV = (string)aboutObject["data"]["cechy"]["wyglad"][2]["value"];
string sylwetkaV = (string)aboutObject["data"]["cechy"]["wyglad"][3]["value"];
string coPiekneV = (string)aboutObject["data"]["cechy"]["wyglad"][4]["value"];
string noszeV = (string)aboutObject["data"]["cechy"]["wyglad"][5]["value"];
string mamV=(string)aboutObject["data"]["cechy"]["wyglad"][6]["value"];
string stylUbieraniaV = (string)aboutObject["data"]["cechy"]["wyglad"][7]["value"];
//CECHY STYLU ŻYCIA//
string mieszkamWV = (string)aboutObject["data"]["cechy"]["styl_zycia"][0]["value"];
string zKimMieszkamV = (string)aboutObject["data"]["cechy"]["styl_zycia"][1]["value"];
string papierosyV = (string)aboutObject["data"]["cechy"]["styl_zycia"][2]["value"];
string AllkoholV = (string)aboutObject["data"]["cechy"]["styl_zycia"][3]["value"];
string wyksztalcenieV = (string)aboutObject["data"]["cechy"]["styl_zycia"][4]["value"];
string UczesieV = (string)aboutObject["data"]["cechy"]["styl_zycia"][5]["value"];
string ZawodV = (string)aboutObject["data"]["cechy"]["styl_zycia"][6]["value"];
string DochodV = (string)aboutObject["data"]["cechy"]["styl_zycia"][7]["value"];
string SamochodV = (string)aboutObject["data"]["cechy"]["styl_zycia"][8]["value"];
string ReligiaV = (string)aboutObject["data"]["cechy"]["styl_zycia"][9]["value"];
//CECHY OSOBOWOŚC//
string ZwiazekV = (string)aboutObject["data"]["cechy"]["osobowosc"][0]["value"];
string Dzieciv = (string)aboutObject["data"]["cechy"]["osobowosc"][1]["value"];
string MalzenstwoV = (string)aboutObject["data"]["cechy"]["osobowosc"][2]["value"];
string PartnerV = (string)aboutObject["data"]["cechy"]["osobowosc"][3]["value"];
string CharaktersV = (string)aboutObject["data"]["cechy"]["osobowosc"][4]["value"];
//Cechy Poszukiwany Ideal//
string MamV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][0]["value"];
string PłećV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][1]["value"];
string wiekV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][2]["value"];
string regionV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][3]["value"];
string charakterV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][4]["value"];
string ZazdrosnaV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][5]["value"];
string SylwetkaV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][6]["value"];
string StylUbieraniaV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][7]["value"];
string ToCośV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][8]["value"];
string WyksztalcenieV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][9]["value"];
string PapierosyV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][10]["value"];
string AlkoholV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][11]["value"];
string PierwszaRandkaV = (string)aboutObject["data"]["cechy"]["poszukiwany_ideal"][12]["value"];
//Cechy ULUBIONE//
string JedzenieV = (string)aboutObject["data"]["cechy"]["ulubione"][0]["value"];
string RozrywkaV = (string)aboutObject["data"]["cechy"]["ulubione"][1]["value"];
string MuzykaV = (string)aboutObject["data"]["cechy"]["ulubione"][2]["value"];
string SportV = (string)aboutObject["data"]["cechy"]["ulubione"][3]["value"];
// TWORZĘ TABLICE//
string[] Wygląd;
Wygląd = new string[8];
Wygląd[0] ="Długość Włosów:"+Environment.NewLine+ dlugoscWlosowV;
Wygląd[1] ="Kolor Włosów:"+Environment.NewLine+ kolorWlosowV;
Wygląd[2] ="Kolor Oczu:"+Environment.NewLine+ kolorOczuV;
Wygląd[3] ="Sylwetka"+ Environment.NewLine+ sylwetkaV;
Wygląd[4] = "Co Piękne" + Environment.NewLine + coPiekneV;
Wygląd[5] = "Noszę" + Environment.NewLine + noszeV;
Wygląd[6] = "Mam:" + Environment.NewLine + mamV;
Wygląd[7] = "Styl Ubierania" + Environment.NewLine + stylUbieraniaV;
label1.Text = "WYGLĄD";
for (int i = 0; i < 8; i++)
label1.Text +=Environment.NewLine+ (Wygląd[i]);
label1.AutoSize = false;
label1.Size = new Size(300, 300);
string[] StylZycia;
StylZycia = new string[10];
StylZycia[0] ="Mieszkam W:"+Environment.NewLine+mieszkamWV;
StylZycia[1]="Z Kim Mieszkam:"+Environment.NewLine+zKimMieszkamV;
StylZycia[2]="Papierosy:"+Environment.NewLine+papierosyV;
StylZycia[3]="Alkohol:"+Environment.NewLine+AlkoholV;
StylZycia[4] = "Wykształcenie:" + Environment.NewLine + wyksztalcenieV;
StylZycia[5] = "Uczę Się:" + Environment.NewLine + UczesieV;
StylZycia[6] = "Zawód:" + Environment.NewLine + ZawodV;
StylZycia[7] = "Dochód:" + Environment.NewLine + DochodV;
StylZycia[8] = "Samochód:" + Environment.NewLine + SamochodV;
StylZycia[9] = "Religia:" + Environment.NewLine + ReligiaV;
label2.Text = "STYL ŻYCIA:";
label2.AutoSize = false;
label2.Size = new Size(300, 300);
for (int i = 0; i < 10; i++)
label2.Text += Environment.NewLine+(StylZycia[i]);
label3.Text = "OSOBOWOŚC:";
label3.AutoSize = false;
label3.Size = new Size(300, 300);
string[] Osobowość;
Osobowość = new string[5];
Osobowość[0] = "Związek:" + Environment.NewLine + ZwiazekV;
Osobowość[1] = "Dzieci:" + Environment.NewLine + Dzieciv;
Osobowość[2] = "Małżeństwo" + Environment.NewLine + MalzenstwoV;
Osobowość[3] = "Partner:" + Environment.NewLine + PartnerV;
Osobowość[4] = "Charakter:" + Environment.NewLine + CharaktersV;
for (int i = 0; i < 5; i++)
label3.Text += Environment.NewLine + (Osobowość[i]);
string [] Ideał;
Ideał = new string[13];
Ideał[0] = "Mam:" + Environment.NewLine + MamV;
Ideał[1] = "Płeć" + Environment.NewLine + PłećV;
Ideał[2] = "Wiek:" + Environment.NewLine + wiekV;
Ideał[3] = "Region" + Environment.NewLine + regionV;
Ideał[4] = "Charakter:" + Environment.NewLine + charakterV;
Ideał[5] = "Zazdrosny/a" + Environment.NewLine + ZazdrosnaV;
Ideał[6] = "Sylwetka" + Environment.NewLine + SylwetkaV;
Ideał[7] = "Styl Ubierania:" + Environment.NewLine + StylUbieraniaV;
Ideał[8] = "To Coś:" + Environment.NewLine + ToCośV;
Ideał[9] = "Wykształcenie" + Environment.NewLine + WyksztalcenieV;
Ideał[10] = "Papierosy:" + Environment.NewLine + PapierosyV;
Ideał[11] = "Alkohol:" + Environment.NewLine + AlkoholV;
Ideał[12] = "Pierwsza Randka" + Environment.NewLine + PierwszaRandkaV;
label4.Text = "POSZUKIWANY IDEAŁ:";
label4.AutoSize=false;
label4.Size= new Size(300,300);
for(int i = 0 ; i <13 ; i++)
label4.Text+=Environment.NewLine+ (Ideał[i]);
string[] Ulubione;
Ulubione = new string[5];
Ulubione[0] = "Jedzenie:" + Environment.NewLine + JedzenieV;
Ulubione[1] = "Rozrywka" + Environment.NewLine + RozrywkaV;
Ulubione[2] = "Muzyka:" + Environment.NewLine + MuzykaV;
Ulubione[3] = "Sport:" + Environment.NewLine + SportV;
label5.Text = "ULUBIONE:";
label5.AutoSize = false;
label5.Size = new Size(300, 300);
for (int i = 0; i < 5; i++)
label5.Text += Environment.NewLine+(Ulubione[i]);
//koniec tablicy formularza user about
aboutReader.Close();
response.Close();
//USER PHOTOS//
string urlPhotos = "http://api.fotka.pl/v2/user/photos?user_id="+id;
request = (HttpWebRequest)HttpWebRequest.Create(urlPhotos);
request.CookieContainer = cookies;
request.Method = "GET";
response = (HttpWebResponse)request.GetResponse();
Stream photoStream = response.GetResponseStream();
StreamReader photoReader = new StreamReader(photoStream);
//ZACZYNAM Parsowanie JSON///
JObject photoObject = JObject.Parse(photoReader.ReadToEnd());
string photoResponse = photoReader.ReadToEnd();
string photoID = (string)photoObject["photos"][0]["id"]; //identyfikator zdjęcia
string Thumb = (string)photoObject["photos"][1]["thumb"]; //URL do miniatury zdjęcia
string uri = (string)photoObject["photos"][2]["url"]; //URL do zdjęcia
string widthUri = (string)photoObject["photos"][2]["width"]; //szerokość zdjęcia
string heightUri = (string)photoObject["photos"][2]["height"]; //wysokość zdjęcia
string albumID = (string)photoObject["photos"][2]["album_id"]; //numer Albumu
pictureBox1.Load(uri);
photoReader.Close();
response.Close();
//USER NOTIFICATIONS//
request = (HttpWebRequest)HttpWebRequest.Create("http://api.fotka.pl/v2/user/notifications");
request.CookieContainer = cookies;
request.Method = "POST";
response = (HttpWebResponse)request.GetResponse();
Stream NotifiStream = response.GetResponseStream();
StreamReader Notifireader = new StreamReader(NotifiStream);
JObject notifiObject = JObject.Parse(Notifireader.ReadToEnd());
string test=(string)notifiObject["notifications"][0]["content"];
test += (string)notifiObject["notifications"][1]["content"];
test += (string)notifiObject["notifications"][2]["content"];
test += (string)notifiObject["notifications"][3]["content"];
test += (string)notifiObject["notifications"][4]["content"];
test += (string)notifiObject["notifications"][5]["content"];
test += (string)notifiObject["notifications"][6]["content"];
test += (string)notifiObject["notifications"][7]["content"];
test += (string)notifiObject["notifications"][8]["content"];
test += (string)notifiObject["notifications"][9]["content"];
test += (string)notifiObject["notifications"][10]["content"];
test += (string)notifiObject["notifications"][11]["content"];
test += (string)notifiObject["notifications"][12]["content"];
test += (string)notifiObject["notifications"][13]["content"];
test += (string)notifiObject["notifications"][14]["content"];
test += (string)notifiObject["notifications"][15]["content"];
test += (string)notifiObject["notifications"][16]["content"];
test += (string)notifiObject["notifications"][17]["content"];
test += (string)notifiObject["notifications"][18]["content"];
test += (string)notifiObject["notifications"][19]["content"];
test += (string)notifiObject["notifications"][20]["content"];
test += (string)notifiObject["notifications"][21]["content"];
test += (string)notifiObject["notifications"][22]["content"];
test += (string)notifiObject["notifications"][23]["content"];
test += (string)notifiObject["notifications"][24]["content"];
test += (string)notifiObject["notifications"][25]["content"];
test += (string)notifiObject["notifications"][26]["content"];
test += (string)notifiObject["notifications"][27]["content"];
test += (string)notifiObject["notifications"][28]["content"];
test += (string)notifiObject["notifications"][29]["content"];
//PARSUJĘ HTML AGILITY //
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(test);
IEnumerable<HtmlNode> links = doc.DocumentNode.Descendants("a").Where(x => x.Attributes.Contains("href"));
foreach (var linkss in links)
{
richTextBox1.Text+=Environment.NewLine+(string.Format("{1}", linkss.Attributes["href"].Value, linkss.InnerText));
}
Notifireader.Close();
response.Close();
}
private void button1_Click_1(object sender, EventArgs e)
{
formaa1.Close();
}
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
formaa1.Close();
}
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e)
{
Process process = new Process();
process = Process.Start("Chrome.exe", e.LinkText);
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start(e.Link.LinkData as string);
}
private void pictureBox3_Click(object sender, EventArgs e)
{
Form3 form3 = new Form3(this);
form3.Visible = true;
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
I Potrzebuję odświeżania informacji np z profilu z fotki poprzez przeglądarke zmieniam dane, aplikację mam załączoną i potrzebuję automatycznego odświeżenia informacji by się pojawiła w aplikacji Proszę o Pomoc.