Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Purple.exe · Oct 30, 2015 at 09:15 PM · wwwinternetautomaticnotificationsblog

Retrieving data automatically from blog website

I'm trying to add notifications in my game that will update automatically when a new blog post is published. Is there a way to do this? I'm fairly new to web integration, so explain it to me like I'm a four-year-old. I don't exactly need an entire script for this, just an explanation with examples. Thanks.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by ttRevan · Oct 31, 2015 at 06:58 AM

You may use a constant polling:

 void Start() {
     StartCoroutine(StartBlogMonitoring());
 }
 
 IEnumerator StartBlogMonitoring() {
     while (true) {
         var rq = new WWW("http://myblog.com/blogposts-list");
         yield return rq;
         var list = Parse(rq.text);
         if (HasNewPost(list))
         {
             PushNotification();
         }
         yield return new WaitForSeconds(2);
     }
 }

It will send a request to a blog site every 2 seconds to retrieve posts list, then check for a new post there and create notification. Instead of posts list, you can use whatever way is appropriate for your blog to check for new posts.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Purple.exe · Nov 02, 2015 at 01:52 PM 0
Share

How should I state these variables?

error CS0103: The name 'Parse' does not exist in the current context

error CS0103: The name 'HasNewPost' does not exist in the current context

error CS0103: The name 'PushNotification' does not exist in the current context

avatar image ttRevan · Nov 05, 2015 at 05:55 AM 0
Share

Well, this is just a placeholder methods I use, you need to write them on your own, depending on what format you use, how you decide that blog post has been created and how you add a notification in your scene.

avatar image Purple.exe ttRevan · Nov 05, 2015 at 03:49 PM 0
Share

I understand that, but what are Parse and HasNewPost doing? Should list be gathering copies of rq and then HasNewPost is checking for differences between the two most recent? And then what is Parse doing? I just have no idea; please explain. Sorry if I'm pestering you.

avatar image ttRevan Purple.exe · Nov 05, 2015 at 05:35 PM 0
Share

Suppose you have a blogging platform that allow you to send request to get the list of all blogs, or just updates, with dates (like rss) in some format (say json or xml). Then

 var rq = new WWW("http://myblog.com/blogposts-list");
 yield return rq;


will execute this request and wait for response and rq.text will contain the response as a string. But working with string directly is very difficult, so you need to parse it to some objects, which you can easily query for properties. And that what Parse method is doing. Exact implementation depends on response format and the library you chose to parse it. For json you have Json.NET, for xml there are a lot of ways to parse it too, however I can't recommend any particular.

So, when you have your response parsed, you need a way to find out which posts are new. And HasNewPost should do it, and yes, it can compare new list with previous one and add notifications for those posts that not exist in later.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Best way to check internet connectivity (Android + iOS) 4 Answers

How to read text file (.txt) from URL? 3 Answers

yield return WWW stops Coroutine? 0 Answers

Google Insights 0 Answers

Problem with WWW.progress 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges