Click here to Skip to main content
15,904,497 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I asked a question about how to get information about a movie from the internet... and someone said "Just use web service methods and get output in JSON Format" - so I want to know how to get output? For example: my software has 5-4 textboxes and it has a search box with a button - so I want my software get info about anything that I'm searching and fill those text boxes with that info. Like when I searched "Iron man" the software get "year(like 2015)" from omdb and put that 2015 on "year textbox". I'm new in C# - can you please show me a code example about how to do that?

http://www.omdbapi.com/?t=Iron%20man[^]

What I have tried:

I asked a question about how to get information about a movie from the internet... and someone said "Just use web service methods and get output in JSON Format" - so I want to know how to get output?
Posted
Updated 16-May-17 15:11pm
Comments
Richard MacCutchan 10-Jun-16 12:52pm    
Your link shows the JSON output from some web service, so that is it. What is the problem?
Johny Flow 10-Jun-16 13:13pm    
I don't know how to write code that my software automatically fill text boxes with those info and save it. ( i want to create something like "movie label" ) movie label : http://www.codeaero.com/movie-label/

AnvilRanger 10-Jun-16 14:41pm    
In a nutshell your question is "How do I write software?" and that is well beyond the scope of of this QA. If you would provide more detail about what you are having problems with we could help you, but you are the best judge of your skills.

You say you are new C# or do you mean to say you are new to development in general. One is the most essential skills you will need as a developer is how to ask a question.

I will assume that you need to know how to call the omdb api and process the JSON. Look at the HTTPClient. And after that look at using Json.NET to handle the working withe the JSON response.
Johny Flow 11-Jun-16 0:05am    
yes, i needed to know how to call the omdb api. thank you.
Johny Flow 11-Jun-16 1:30am    
please take a look at this - this is my question.
http://www.codeproject.com/Questions/1105851/How-to-get-movie-information-from-imdb-in-Csharp

1 solution

try this

Create a class like this

C#
public class ImdbEntity
  {
      public string Title { get; set; }
      public string Year { get; set; }
      public string Rated { get; set; }
      public string Released { get; set; }
      public string Runtime { get; set; }
      public string Genre { get; set; }
      public string Director { get; set; }
      public string Writer { get; set; }
      public string Actors { get; set; }
      public string Plot { get; set; }
      public string Language { get; set; }
      public string Country { get; set; }
      public string Awards { get; set; }
      public string Poster { get; set; }
      public string Metascore { get; set; }
      public string imdbRating { get; set; }
      public string imdbVotes { get; set; }
      public string imdbID { get; set; }
      public string Type { get; set; }
      public string Response { get; set; }
  }


use the below code to fill the values of the movie information into the respective text-boxes,
customize it based on your need.

C#
private void btnSearch_Click(object sender, EventArgs e)
       {
           string url = "http://www.omdbapi.com/?t=" + txtMovieName.Text.Trim();
           using (WebClient wc = new WebClient())
           {
               var json = wc.DownloadString(url);
               JavaScriptSerializer oJS = new JavaScriptSerializer();
               ImdbEntity obj = new ImdbEntity();
               obj = oJS.Deserialize<ImdbEntity>(json);
               if (obj.Response == "True")
               {
                   txtActor.Text = obj.Actors;
                   txtDirector.Text = obj.Director;
                   txtYear.Text = obj.Year;

               }
               else
               {
                   MessageBox.Show("Movie not Found!!!");
               }


           }
       }


Note: Refer this dll (System.Web.Extensions.dll ) to your project
C#
using System.Web.Script.Serialization;
 
Share this answer
 
Comments
Johny Flow 11-Jun-16 1:40am    
thank you so much man. thats what i want. thanks again. just one question : it just say movie not found - i did everything correct!
Karthik_Mahalingam 11-Jun-16 1:59am    
ImdbEntity is just a class with the properties relevant to the JSON from the Site..

we are just converting the json object to a ImdbEntity class, so that we can access the properties directly
Johny Flow 11-Jun-16 2:01am    
i can't fix it(i want to show you my program and get help) - do you have whatsapp or telegram or yahoo messenger ?
Karthik_Mahalingam 11-Jun-16 2:11am    
post your entire code..
Johny Flow 11-Jun-16 2:13am    
http://s000.tinyupload.com/?file_id=14224732452825347315

i put my project there

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900