Page 1 of 1

httpget inside custom JS with FAcebook Publishing APIs

Posted: Sun Jan 26, 2014 5:54 pm
by Roger6240907

I am using the Facebook Publishing APIs. When I read the feed I would like to invoke a http get request to my server to modify the display status string.

This is the code in the plugin that works to display the status feeds:
code
var feedId = value.id,
feedMsg = value.story || value.message,
feedBtn = element.find('[name=feed_name]');

feedBtn.find('.ui-btn-text').text(feedMsg);
feedBtn.attr('data-id', feedId);
/code

feedMsg is the text of the status feed returned from the Facebook APIs. I need to make an httpget request to my server like:
code
var r=httpGet('http://myserver/getStatus/'+escape(feedMsg));
/code

I return a JSON object, the element 'status' contains the new string to display.

Thanks for your help,
Roger


httpget inside custom JS with FAcebook Publishing APIs

Posted: Sun Jan 26, 2014 6:19 pm
by Igor

Hello,

Please try to use REST service instead of httpGet function. http://docs.appery.io/documentation/r...


httpget inside custom JS with FAcebook Publishing APIs

Posted: Sun Jan 26, 2014 6:24 pm
by Roger6240907

The problem is that I need to execute it for every item returned from the Facebook API. So I can call the REST from the custom JS, how can I update the correct UI element when each REST request returns its correct value?


httpget inside custom JS with FAcebook Publishing APIs

Posted: Sun Jan 26, 2014 6:46 pm
by Igor

You need to create REST get service and map service response to UI component. Then you can invoke this service from JS http://docs.appery.io/documentation/r... and it will update UI component.


httpget inside custom JS with FAcebook Publishing APIs

Posted: Sun Jan 26, 2014 6:58 pm
by Roger6240907

This is what I do with the Facebook APIs, have them mapped them to UI (this is phase 1 and it is working), now I need to invoke my REST service for each element returned by Facebook APIs. This is the question.

So to simplify I need to call 2 REST services in series, the first one maps to UI and return something like {'v':1; 'v':2, 'v':3} and by itself it will create 3 buttons labeled 1,2, and 3. This is working.
Now for each element of UI I want to call the second REST service that will take 1,2,3 and make 4,5, and 6 by executing 3 REST calls. This results in 3 buttons labeled 4,5 and 6. I hope this can clarify what I'm trying to do.


httpget inside custom JS with FAcebook Publishing APIs

Posted: Mon Jan 27, 2014 6:44 pm
by Kateryna Grynko

Hi Roger,

Not sure we fully understand what your need. Most probably, you should invoke service for each record within JavaScript code added to component mapping.