Get stream of new Facebook likes for your application - c#

Is it possible to get response from Graph API (or FQL) that will list new likes for application and objects tied to it? Meaning - I created application, posted Like buttons all over the site - can I now get feed that will tell me what are the last 10 likes my pages received?
Related - can I somehow get list of last 10 likes of my Fan Page (something like New Likes box in Admin section)?

There is no public Facebook API that will allow you to receive a stream of the most recent likes for a collection of objects.
Furthermore, it doesn't appear to be possible to obtain a stream of likes ordered specifically by time, however it is possible to receive a list of user IDs who liked an object using the like FQL table.
like: An FQL table that returns the IDs of users who like a given object (video, note, link, photo, or album).
For example, to retrieve a list of all the user ids who liked the 'Facebook' page, you would use the FQL query:
SELECT user_id FROM like WHERE object_id="122706168308"
Which would return a list similar to this:
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
<like>
<user_id>100003494051884</user_id>
</like>
<like>
<user_id>100003621882407</user_id>
</like>
<like>
<user_id>100003664580513</user_id>
</like>
<like>
<user_id>100002342537723</user_id>
</like>
<like>
<user_id>100001712929866</user_id>
</like>
<like>
<user_id>100003278394112</user_id>
</like>
</fql_query_response>
The order of the user IDs isn't clear - it may be in no specific order, or it may be ordered by time. I'd recommend that you have a bit of a fiddle with FQL and likes to see if it is in any particular order. You should also take a look at the other examples documented here.
As mentioned by Roni, it is possible to use the notifications RSS feed of your page to retrieve an RSS 2.0/XML feed of all notifications, sorted by time.
It may be possible to parse that XML to find the users who most recently liked your page, but the feed can get messy: it basically contains the HTML for each notification on the notifications page.

Question #1:
You can use Real-time Updates
Here are the steps to set up a subscription:
Set up an endpoint URL that receives both HTTP GET (for subscription verification) and > POST (for actual change data) requests from Facebook.
Make a POST to the graph API url https://graph.facebook.com//subscriptions to > subscribe, and be ready to handle the verification request.
What you get:
User connections to which you can subscribe: feed, friends, activities, interests, music, books, movies, television, likes, checkins.
What you don't get (yet):
home, tagged, posts, photos, albums, videos, groups, notes, events, inbox, outbox, updates, accounts.
Question #2:
Sure you can !
go to your Page Notifications (replace XXXX with your page ID)
you will find there an RSS link which you can use without even making a Graph API call
You will receive notifications when visitors interact with your page.
For example, if a visitor likes your page or a fan writes on your
wall, you will receive a notification.

Related

Get more facebook comments using Skybrud

I'm developing an app which connects to a specific public page on facebook and search for the comments in a specific post, we have to look all the posts in order to find specific hashtags but there's one post with 4000+ comments, facebook throws this exception:
'StackTrace: Skybrud.Social.Facebook.Exceptions.FacebookException: Please reduce the amount of data you're asking for, then retry your request
at Skybrud.Social.Facebook.Responses.FacebookResponse.ValidateResponse(SocialHttpResponse response, JsonObject obj)
at Skybrud.Social.Facebook.Responses.Comments.FacebookCommentsResponse.ParseResponse(SocialHttpResponse response)
at Skybrud.Social.Facebook.Endpoints.FacebookCommentsEndpoint.GetComments(String id, FacebookCommentsOptions options)'
As you can see I'm using Skybrud, I limited the comments to 800 and it works, but there are more comments and I don't know how to retrieve the other pages of comments, any ideas?.
Thanks for your time.
Maybe this could help someone else, use the two members from the FacebookCommentsOptions: Before and After, the response from Facebook will include this in the Paging section. Then call again the GetCommets method.

Any downsides to replacing REST endpoints with SignalR?

I'm building a fairly simple single page app. It's basically a list of items, where each item has some details, an activity log, and a current status along with some buttons to trigger actions on the server to advance the status along a workflow.
It was originally written using MVC and REST/Web API but I got stuck on the problem of keeping concurrent users up to date. For example, if User A adds an item, we want the list on User B's screen to now update to include it.
To solve this I looked into SignalR which works great. But I had a problem.
When adding an item (using POST) the callback adds the item on the requesting client. This is fine.
I then triggered a SignalR broadcast on the server to tell all clients about the new item. This worked fine except the local client, who now has 2 items.
I was looking into filtering the duplicate id client-side, or sending the connection id with the POST, then broadcast to all clients except the requester but it seems a bit needlessly complicated.
Instead I'm just doing this.
public class UpdateHub : Hub
{
public void AddNewItem(NewItem item)
{
// and some server-side stuff, persist in the data store, etc
item.trackingID = new Guid();
item.addLogEntry("new item");
// ...
dataStore.addItem(item);
// send message type and data payload
Clients.All.broadcastMessage("add", item);
}
}
It seems a lot simpler to just get rid of all the REST stuff altogether, so am I missing anything important?
It'll run on an intranet for a handful of users using IE11+ and I guess we do lose some commonly-understood semantics around HTTP response codes for error handling, but I don't think that's a huge deal in this situation.
In order to solve duplicate you can try to use Clients.Others inside Hub class, or AllExcept(id) if you not in the Hub class.
Clients.Others.broadcastMessage("add", item);
In your case using SignalR shouldn`t have any downsides.

post for specific group in Facebook for new changes?

it is been few days that I can not post a message from my app to specific groups of friends in Facebook, I am using asp.net MVC, before that I was using following code to post for only one list of friends " for example: close friend" but now it always post to all friends even when I specify target group.
FacebookClient fpost1 = new FacebookClient(context.AccessToken.ToString());
fpost1.Post("/me/feed", new { message = "test message", to = "xxxxxxxxxxxxxx" });
what should be changed to post for only specific list. consider xxxxxxxxxxxx as a close friend list id.
Assuming your app is a website, the easiest way to do this is to just use the share button and let the user pick the group he wants to post to.
https://developers.facebook.com/docs/plugins/share-button/
If your app is mobile, you can use the Share Dialog
https://developers.facebook.com/docs/ios/share
https://developers.facebook.com/docs/android/share

Bloomberg API - get list of government bonds

When hitting KENGB <Govt> <GO> on the Bloomberg terminal I get list of all Kenya government bonds.
How do I get this list through Bloomberg API? Or list of their tickers?
(I download PX_LAST prices and historical prices for various securities regularly, so I am pretty familiar with service "//blp/refdata" and request "ReferenceDataRequest" ... but cannot figure out how to retrieve list of securities (and its tickers) programmatically)
try to take a look at this:
http://www.openbloomberg.com/content/uploads/sites/2/2013/04/blpapi-developers-guide.pdf
at page 77 it explains which service you must call to have Government Bonds.
this is teh c++ code:
Service govtService = session.getService("//blp/instruments");
Request request = govtService.createRequest("govtListRequest");
request.asElement().setElement("partialMatch", true);
request.asElement().setElement("query", "T*");// this plus the previous line permits to retrieve all the thicker that begins with T
request.asElement().setElement("ticker", "LANG_OVERRIDE_NONE");
request.asElement().setElement("maxResults", 10);
sendRequest(request, session);
The only way I know to get a list of securities via API v3 is to use the EQS API where you set up an EQS screen and then use the API to get the matching securities. Not sure if this lets you achieve the same result you get from security search on the Terminal.

Mailchimp Campaign Send Error - This Campaign has already been sent and can not be sent again

I have a Mailchimp RSS campaign that reads an RSS feed on a website and is set to once a day. I would like to send this campaign pro-grammatically after I add an item to the feed.
I am using PerceptiveMCAPI and My code for triggering the campaign is
campaignSendNowInput campaignSendNowInput = new campaignSendNowInput(apiKey, campaignKey);
campaignSendNow campaignSendNow = new campaignSendNow(campaignSendNowInput);
campaignSendNowOutput campaignSendNowOutput = campaignSendNow.Execute();
The error I receive looks like
"Error Code: 313, Message: This Campaign has already been sent and can not be sent again."
Any ideas on what would be causing this?
Well, I think after looking this over a bit more I originally had the wrong logic. The correct way I believe is to create a new campaign each time and then send this new campaign. Campaigns are meant to be sent once.
RSS feed announcements in Mailchimp are limited to once a day therefor you need to use a standard campaign which you can create pro-grammatically and send that campaign off. If it is vital that the content come from an RSS feed you can still use an RSS feed using the RSS merge tags.

Categories