last day (15 days later) » 

4:34 PM
0
Q: cannot access data property of undefined when retrieving facebook comments

user3832583My issue seems to be retrieving comments from the users feed from facebook. It gets the type and the message properties just fine. So I can use them within the control structure to output what I want. However, the comments property is acting strange. The console seems to throw the error cannot ac...

 
We need more details: What api endpoint are you calling? Are you sure it has the message property? Do you have a JSfiddle for this? In other words, can we see your code?
 
It does have the message property, but I will probably have to create a stripped down working version of it on jsfiddle.
Actually I don't think I will able to get jsfiddle up as I would expose information that would be private to my facebook account in order for it to work.
 
Ok, tell me the API endpoint, and give me more code(apart from the personal information).
 
Sorry just figured out my issue it was partly due what you suggested. However, when I stripped down the code I forgot to include the else if where feed[item].story === undefined. I also had to make sure to test for feed[item].comments !== undefined so it wouldn't get to the point where it can throw the error
 
Please edit the code: the if-else part seems to do the same as the if part.
Hi
"even if I log the current feed[item] I get undefined"
Is it so?
 
4:39 PM
Sorry maybe there is some misunderstanding. It seems to be working fine now. I reviewed my code again, and your comment. "Are you sure it has the message property?". So I noticed that I was not testing it in the right part of the if-else.
I was testing it under the code where it said message === undefined which at the time made sense, but it was just a long night, and I confused myself.
 
So it never had the message property?
 
No it did not. I was under the assumption I was in the code block for the message property but I was in the one for the story if that makes sense?
Thanks a lot for your help though. I was just looking at it for too long.
 
Oh right. Got it. Glad it's solved for you :)
 
Yeah thanks if you want you can add it to the question so I can mark you down for getting me to answer?
 
No, it's not really an answer, thanks :) Are you working with Facebook api, how are you getting the access tokens?
 
4:51 PM
Well I am working with the php sdk. So I have built a manual login, and I get the access token from there when I ask the user for permissions and such. If that is what you meant?
So I am working with the api
Have you done any work not using the api?
 
I had used it once, jsfiddle.net/kkab/5pfo8qck
But the problem was only I could post to Facebook, as the access token were specific to me. I think once we send the app for approval, everyone can use it.
 
5:08 PM
Oh yeah well that looks interesting. I have always want to know about getting longer access tokens haven`t really the time read into it though.
wanted*
Have you not set your app up on the facebook developers page? I have never had to get it approved and people can use it(unless it was review without my knowledge).
 
I set up the app on Facebook, but never sent it for review. I am still only developing it. So far it posts status with a image.
FB's docs are brilliant, it will be well worth your time, to read it. They are clearly written.
 
Yeah I have been trying to familiarize myself with them some more.
How long have you been working on this project?
 
5:26 PM
I worked on this and then side by side, I was developing authentication for my web application and faced some trouble, as I was not aware of sessions and was using variables in nodejs to keep track of which user is logged in, a bad bad idea :) For instance, if you log in, and then i log in, and you see your photos, it will show my collection.
So, I thought, enough of playing with javascript blindfoldedly, and learned the language, it's a beautiful language, if you sit down and play with it for some time. It is a dense language.
 
Yeah it is a really powerful language, yet I can get so frustrated with it at times.
I am currently trying to learn angular. I haven't gotten into nodejs yet though.
I assume you have a background in computer science though? Like, C++ and such.
 
Yes, I studied C++ in my school days and in my college days. Now however I said to myself, "I 'm done with C++, let me learn the language of the web." :)
How about you?
 
5:41 PM
I am currently doing a CS degree(learning to use java at the moment), however the web has always caught my interest. So I have just been learning javascript, html, css, and php so I can actually make some webapps.
So do you do any freelance work at all, or do you still find you have some work you need to do to get to that level using javascript?
 
6:38 PM
I do not do freelance, I am just a beginner, I would love to try one day though. Do you freelance? If yes, tell me more :) Right now, I am humble learner, I am learning by myself and experimenting various things, so it's a lot of fun :)
 
6:49 PM
Well I have done a few projects mainly small ones. Nothing too crazy. I also mostly just code to learn, and experiment with my own projects, but as time goes on I am trying to build a portfolio and get involved with some start ups.
Have you done anything on a big scale using C++
?
 
No, I worked on C++ only for algorithms, and it's implementations, I used to do TopCoder then. You are starting at a great time. :) IT would be cool if you build a portfolio, then startups will take you easily.
"few projects"... on C++?
 
I have actually not yet gotten into C++ although I would like to when I get the chance as some projects I would like to do require a full on programming language(not to say Java isn't).
Good to hear that I am starting at a good time though :)
How about you have you given start up any thought?(like making your own or joining one)
I know you said you are a beginner, but do you think about it anyways..
 
I do not think I am a good fit to do a startup, despite that, I love creating new applications, the process is fantastic, and hence, I will do it for my own interest, and have no intention of trying to sell it :) I will contribute to open-source, if I can. I am starting slowly, and I am sure, I will end up in a stage, where I can see 1000's of lines of javascript code and make sense of it. I motivate myself thinking of such a day where I will be a go-to person for javascript. I would love that.
Just few mins I wrote this answer: stackoverflow.com/questions/26915117/…
Felt good to write down what I understand and think out loud and ask myself questions.
.
 
7:07 PM
Yeah well that is great regardless. If you do ever get to do an open source project. I would love to contribute as I am myself just starting to get into open-source projects.
I know what you mean with trying to motivate yourself thinking of becoming a go-to person.
you wouldn't happen to have a linkedin profile would you?
still reading your answer. Very thorough.
 
I don't have a linkedin profile. yes, I wrote it long to tell many things :)
 
Too bad. I have just recently started mine to start networking as I want to finally get established with the community as much as possible.
 
You can hang out in IRC rooms, and find some great people there
 
True. I haven't really spent enough time there.
I should get talking to some folks there.
So you got any ideas for some open source projects?
 
7:25 PM
I have one, I want to write a library that can get you started easily in hackathons, basically, if we are going to create a new app, there are some basic things we all want to do: set up a server, set up a database, send mail to users, chat room within your users, upload images to your server, facebook and twitter integration. That's my idea.
The whole point of this library is that I want people using it to know what is happening in the code, because you know it;s easy to use a 3-rd party library, but things can go crazily wrong, if you face a issue and have no clue, so it makes sense to know what's going on in the code we use from them.
 
That's a cool idea.
Have you given any thought as to how you would go about this library?
Like the facebook/twitter integration would take time, but would be do-able.
funny enough I just got an email about a hackathon
 
The answer to everything is in Javascript, as I am concentrating on the stack: JAvascript for front- end, MONGODB for backend and NodeJS for server. So it's javascript everywhere. :) That is why in the last month, I learned Javascript as much as I could. Still a long way to go.
 
Ok so you are work with the MEAN stack
Or well for the most part
I have thought of given javascript for front and back end a try
I just don't like the prototypical inheritance
 
Once I am comfortable with functions and objects in Javascript, I will start reading code from libraries, and then read API's and write my own little library. So far I have all these(except fb and twitter integration) tasks done with third party code. Now I will explore them, explain them to myself and write it all down.
 
cool. Do you have it up on github or some sort of open-source version control?
 
Yeah I will definitely be following your projects, and hopefully I will be able to contribute some as well.
 
I will go off now ,see you, you can send me a mail if you want. aravindbharathykk@gmail.com, what's yours?
 
webmasterhuwiler@gmail.com
Alright Talk to you later
 
I am just realising I do not know your name :) What's your name?
 
Samuel
 
7:51 PM
:) Bye
 

last day (15 days later) »