Friday, 15 February 2013

javascript - params with fb js sdk -



javascript - params with fb js sdk -

hey guys new javascript facebook sdk .when larn params in javascript sense confused.my code is

var body = 'reading js sdk documentation'; fb.api('/me/feed', 'post', { message: body }, function(response) { if (!response || response.error) { alert('error occured'); } else { alert('post id: ' + response.id); } });

this code works ..but uncertainty can utilize code like

var body = 'reading js sdk documentation'; fb.api('/me/feed?message=body', 'post', function(response) { if (!response || response.error) { alert('error occured'); } else { alert('post id: ' + response.id); } });

is there problem sec type of code ..can done in fb js sdk ..

hope guys can help me ..thanx in advance

it works.. allow me explain bit.

fb.api() method declared follows

fb.api(path, method, params, callback)

the method parameter given here "post" equivalent html post. per api documentation posting feed should done post method. post method, on safe side pass parameters through params

lastly javascript syntax. here body variable should fb.api('/me/feed?message='+body,... or text body posted feed

try out code in test console see documentation more details

javascript facebook facebook-graph-api

No comments:

Post a Comment