tags:

views:

50

answers:

1

Here is my code to query all comments for post_id. When i run it. i cannot get text or id of comment.

var queryTemplate = "SELECT text FROM comment WHERE post_id ='1756044141_155528821125475'";
var u2 = FB.Data.query(queryTemplate);
        FB.Data.waitOn([u2], function(args) {
       //console.log(args[0]);
        alert(args)
});

for console.log(args[0]), it show me empty []. for alert(args), it show me empty also.

i use this queryTemplate in facebook test console, it work! But when i use in my website, it doesn't work.

here is facebook console show me

[ { "text": " น่ากลัว " }, { "text": "เผลอๆเงินเดือนพวกนี้อาจสูงกว่าวิศวกรหรือหมออีกก็เป็นได้..... ^^"" }, { "text": " อาจช่าย คงจะแพงน่าดู" }, { "text": "ดีนะรอดมาได้ " }, { "text": "@Chalita จริงไหม เรียนวิศวะ ในมหาลัยยังไม่เสี่ยงตายเท่าเรียนช่างกลเลย

@Mat ยินดีด้วยนะ ได้ข่าวว่าตอนนี้รถคุณแรงน่าดูเลยหนิ 5555+" }, { "text": "อัลฮัมดุลิ้ลลาห์

ฮ่าๆๆ ก็ได้บรรดานักแข่งอย่างพวกคุณๆอะแหละ มาฝึกปรือให้

ฮ่าๆๆๆ" }, { "text": "Perfect ตลอด" }, { "text": "ได้ข่าวว่าจะซื้อเหรียญนี่คุณรีม ฮ่าๆๆ" }, { "text": " เรียกนาละกันนะ วิศวะปลอดภัยกว่าจิง ทำไมต้องฆ่ากันด้วยเรียนเพื่อเอาวิชาความรู้นะจิงป่ะ " }, { "text": "ถูกกกกก" }, { "text": "ช่าย บางที รร พวกช่างอาจต้องปิดตัวลง เพราะปัญหาเหล่านี้คงแก้ยาก" } ]

here is my website show

[]

I already fix it

Just pust Fb query in FB.getsession such as

FB.getLoginStatus(function(response) {
          if (response.session) {
            var post_id = '1756044141_155528821125475';
            var queryTemplate = "SELECT comments FROM stream WHERE post_id ='1756044141_155528821125475'";
            var u2 = FB.Data.query(queryTemplate);
            FB.Data.waitOn([u2], function(args) {
                console.log(args[0]);
                //alert(args)
            });
          } else {
            // no user session available, someone you dont know
          }
        });
+1  A: 

That's why firebug was invented. Once you installed it you can do

    function(response) {
        console.log(response);
    }

and see everything what is returned. You would need to do something like response[0].text to get what you need.

Also there is no id field in the comment table. there is, my bad

serg
@serg, It's show me Object {}. What wrong for my FQL?
Giffary
Try to paste your fql to a test console and see what is returned: http://developers.facebook.com/docs/reference/rest/fql.query (you need to be logged in to fb)
serg
in my test console it work, but when i use on my site it alway return Object {}.
Giffary
@Giffary try to use `FB.Data.query` instead of `FB.api`: http://developers.facebook.com/docs/reference/javascript/FB.Data.query
serg
@serg i try to use FB.Data.query instead of FB.api but it show me expected ; in restserver.php how can i fix it?
Giffary
@Giffary You mean `FB.Data.query` works correctly? If it doesn't work in php then maybe you are not passing correct access token. In firebug you can see what parameters are being sent during FQL request. Compare them to what you are sending through php. Maybe create another question and post some PHP code.
serg
@serg i use it in javascript. I copy and paste that query to facebook test console, it's work. but when i use in my website, it's not work. I'll edit my question to update my problem. Can u fix it?
Giffary
@serg, I fixed it. thank you for your advice. nice to meet you
Giffary