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
0
Question by VIVEKraghu · May 05, 2016 at 06:57 AM · ioscoroutineyieldwww classhttpwebrequest

WWW yield is not returning any value in ios for yahoo finance api

Hi All,

I am getting the stock value from yahoo finance and displaying it in a Text UI component. The below code is working fine in Windows PC, Mac, Android mobile but not in iOS. Code is not getting executed after " yield return wwwEricA;" only for yahoo finance http link "http://finance.yahoo.com/d/quotes.csv?s=ERIC-A.ST&f=sl1d1t1c1p2ohgv&e=.csv" . For testing i have given "https://www.google.co.in/" and that is returning value in ios mobile also. So i guess the problem is only with that particular yahoo URL but could not find what is that. Please help me to solve this issue.

Code :

     public Text EricAStockText;

  private WWW wwwEricA;
  private string stockUrlEricA;
 private string[] stockArrayEricA;
  private char[] seperators = { ',' };

 void Start()
     {
            
     stockUrlEricA = "http://finance.yahoo.com/d/quotes.csv?s=" + WWW.EscapeURL("ERIC-A.ST&f=sl1d1t1c1p2ohgv&e=.csv");
     StartCoroutine(GetStockValueA(stockUrlEricA));
 }

   private IEnumerator GetStockValueA(string URL)
     {
         wwwEricA = new WWW(URL);
         yield return wwwEricA;

         stockArrayEricA = ParseStockValue(wwwEricA.text, seperator);
         EricAStockText.text = stockArrayEricA[1]; 
     }

  private string[] ParseStockValue(string valueString, char[] seperator)
     {
         return valueString.Split(seperator, System.StringSplitOptions.RemoveEmptyEntries);
     }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · May 05, 2016 at 10:19 AM

You use "EscapeURL" wrong. You escaped the "&" in your URL but you actually want them there. Your generated URL would look like this:

 "http://finance.yahoo.com/d/quotes.csv?s=ERIC-A.ST%26f%3Dsl1d1t1c1p2ohgv%26e%3D.csv"

So your "equals" (=) and "ampersands" (&) are replaced with %26 and %3D. So the server only sees one parameter ("s") which contains that rest as one string.

You should only exscape the content of your URL parameters.

 stockUrlEricA = "http://finance.yahoo.com/d/quotes.csv?s=" + WWW.EscapeURL("ERIC-A.ST") + "&f=" + WWW.EscapeURL("sl1d1t1c1p2ohgv") + "&e=" + WWW.EscapeURL(".csv");

This would be the correct way to form your URL. However if you use a hardcoded URL you don't need EscapeURL at all since your data don't contain any problematic characters.

See URL Encoding for more details.

Comment
Add comment · Show 1 · 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 VIVEKraghu · May 05, 2016 at 03:33 PM 0
Share

@Bunny83 Thanks for your suggestion, actual problem is with the URL This below URL solved the problem "http://download.finance.yahoo.com/d/quotes.csv?s=ERIC-A.ST&f=sl1d1t1c1p2ohgv&e=.csv"

avatar image
0

Answer by Harrymon12 · Jul 12, 2017 at 03:42 PM

Yahoo finance API is not available anymore. I have moved to MarketXLS after this change, much more reliable data.

Comment
Add comment · 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

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

www class blocks script execution 1 Answer

Ios problem with www class 2 Answers

Null Reference Exception after updating from 4.0 to 4.1.5 (coroutines) 0 Answers

Question about WaitForFixedUpdate() 1 Answer

Stop the Awake() until a user clicks a button? 1 Answer


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