how to get the fan page name of Facebook wall post? - user-interface

I am reading the wall posts of fan pages under my FB account using C# SDK. I would like to know the page id of the wall post. Is there any property in C# SDK?

As people start to use the Graph objects more an more, the FQL seems to be fading. But FQL is not deprecated (at least not yet).
For a particular wall post you're reading via your C# SDK, simply FQL it:
SELECT source_id FROM stream WHERE post_id = {post_id}
For more information https://developers.facebook.com/docs/reference/fql/stream/
For information on how to make an FQL query run in the C# SDK, see:
http://blog.prabir.me/post/Facebook-CSharp-SDK-Making-Requests.aspx
But it's going to look something like this
var client = new FacebookClient(access_token);
// this is where you already grab your post, so you have post_id
var data = client.query("SELECT source_id FROM stream WHERE post_id =" + post_id);

Related

Youtube Api no result issue

I'm trying to use Youtube Api V3 to get documentaries videos, unfortunately I can't get any results for many searched keys.
Is there any advanced configuration I can use to get more results or is there any alternative API(s) ?
this is my query
https://www.googleapis.com/youtube/v3/search?part=snippet&q=alien&type=video&videoCategoryId=35
First and foremost make sure you have an API_KEY. Follow link for details, then go to developer console to get one.
Then your request URL should look like this.
var API_KEY = "your api key";
var channelID = "The channel id u wan to pull";
var result = 30 // Limit the number of videos
`https://www.googleapis.com/youtube/v3/search?key=${API_KEY}&channelId=${channelID}&part=snippet,id&order=date&maxResults=${result}`
With an API key, I also pulled 0 results for 'alien' in the Documentary category. Perhaps there aren't any.

facebook userid from username in excel power query

I have been spending time on excel power query in the past two days but did not figure out how to fetch facebook userid if i have the username.
For instance, if I have the username zuck OR
the profile url https://www.facebook.com/zuck
using any of the above, is it possible to find the uid (facebook numeric id). In this example, the ID is 4
Somewhat similar to what http://findmyfbid.com does, I want to find out if it is possible with excel power query.
Thanks
Looking around the Power Query Facebook connector and the Facebook Graph API reference I can't find any obvious way to look up user id's from the username.
http://findmyfbid.com/failure indicates that a search engine had to index the public usernames in order to find the id. You can open a page like https://www.facebook.com/Code.org/ in your browser and muck through the HTML and find the username yourself, assuming the page is still public.
On the other hand, findmyfbid.com has already solved this problem. Here's how to query against their website directly using a custom Power Query function FindId:
let
// Assume you've already URL-encoded the id
FindId = (id as text) as text =>
let
Source = Web.Contents("http://findmyfbid.com/", [
Content = Text.ToBinary("url=" & id),
Headers = [#"Content-Type"= "application/x-www-form-urlencoded"]
]),
// Web.Page can't POST directly, so force Web.Contents to execute the POST
WebPage = Web.Page(Binary.Buffer(Source)),
// Hopefully findmyfbid.com doesn't change their HTML layout
DrillDown = WebPage[Data]{0}
{[Name="HTML"]}[Children]
{[Name="BODY"]}[Children]
{[Name="DIV"]}[Children]
{[Name="DIV"]}[Children]
{[Name="CODE"]}[Children]
{[Kind="Text"]}[Text]
in
DrillDown,
ExampleCodeOrg = FindId("code.org")
in
ExampleCodeOrg
And you find that Code.org has an Id of 309754825787494.

Facebook like an object

Need help with Facebook SDK Php Facebook Like.
My website fetches Logged in FB User's Timeline and user can Like posts in his timeline.
Posting Likes works for me successfully. But my question is how should I know he had already liked the post.
I want to show Like button if he has not liked that object and unlike button if he has already liked it.
PS: I tried collecting all the list of users who liked and then compared it with logged in user's fb id, but this method takes long time if likes are more than 10k.
Is there any other methods to accomplish this task.
I am using facebook-php-sdk-v4-4.0-dev
PS: My code for showing his feed is:
(new FacebookRequest($session, 'POST',"/me/feed", $params))->execute()->getGraphObject()->asArray();
The only solution available now is looping through the list of likes like you do , as of now .
there is another solution using FQL
select user_id from like where object_id=your object_id AND user_id=me()
but the problem is that he LIKE table only considers videos, notes, links, photos and albums, not posts.
check facebook fql like documentation . also note that fql is on track for full deprecation .
May be this will help you
$fql= "select user_id from like where object_id=REQUIRE_OBJECT_ID_HERE AND user_id=me()";
$request = (new FacebookRequest($session, 'GET', "/fql?q=$fql"))->execute()->getGraphObject()->asArray();
Change REQUIRE_OBJECT_ID_HERE variable to the id that you need.

Update model attribute without refreshing database

I'm building a website listing poker tournaments. I would like to allow user mark some tournaments as his favourite and avoid forms or extra page with GET parameter - I would like to to update it without refreshing website. From what I understand, it's done by ajax and jquery. But there are many ajax libraries and I would like you to tell me, which one should I use and how to do this simple functionality best.
This is my tournament table:
I would like to have another column before event time, that would contain image for heart. It would be black (not favourite) and if user clicks on it, it would turn red (favourite).
I think m2m relationship should be used here. This is my tournament model.
class Tournament(models.Model):
favourite = models.ManyToManyField(User)
date = models.DateTimeField('Event time')
currency = models.CharField(max_length=5, choices=CURRENCIES, default='USD')
name = models.CharField("Tournament name", max_length=200)
prize = models.DecimalField(max_digits=20, decimal_places=2)
entry = models.DecimalField(max_digits=20, decimal_places=2)
fee = models.DecimalField(max_digits=20, decimal_places=2)
password = models.CharField("password", max_length=200)
type = models.ForeignKey('room.Type')
room = models.ForeignKey('room.Room')
requirements_difficulty = models.IntegerField('Tournament Difficulty',
validators=[MinValueValidator(1), MaxValueValidator(30)])
requirements_text = models.CharField("Requirements Description", max_length=1000)
recurrence = models.CharField(max_length=5,
choices=RECURRENCE_CHOICES,
default='NONE')
So how do I add m2m relationship between user and tournament? Do I use ajax code or dajax? How do I create this m2m without refreshing page?
So how do I add m2m relationship between user and tournament?
Assuming that you use the default django user model:
Class Tournament(models.Model):
user = models.ManyToManyField(settings.AUTH_USER_MODEL, related_name='user_tournament')
...
Do I use ajax code or dajax?
As #doniyor said, you should define your real problem and split your question. SO is not "do it for me", anyway, what I can do for you, is give you some good links ;)
W3 schools definition for ajax:
http://www.w3schools.com/ajax/ajax_intro.asp
Good ajax plugin for djando that seems you already know:
http://www.dajaxproject.com/
By the way, you should use dajax, is easy and faster to create ajax pages integrated with django (you just have to follow the tutorials, is pretty simple).
How do I create this m2m without refreshing page?
Using dajax

reading RSS returns different response on localhost

im trying to parse an rss feed on localhost, and it brings back the right results, but when i try to do that from another (preproduction server) and live, it returns a list of comments made by users on the hydrapinion website which is completely unrelated, have i been spoofed? how can i debug this? its just an rss feed and a simple LINQ code!
string bingurl = "http://www.bing.com/search?form=QBRE&filt=rf&qs=n&format=rss&count=10&q=+environment+(site:www.australianit.news.com.au)";
XDocument doc = XDocument.Load(bingurl);
IEnumerable<XElement> items = (from i in doc.Descendants("item")
orderby DateTime.Parse(i.Element("pubDate").Value) descending
select i).Take(10);
rpData.DataSource = items;
rpData.DataBind();
i tried a different combination, and i get no results at all! do u think the server settings have antyhing to do with retrieving rss results?
i found some decent guide for bing search, but as it turned out, bing doesnt bring decent resuls! and it appears to me it changes the results set according to where ur calling it from, i tried adding "loc:" to the rss, when called from code it returned different results than when called on bing website itself, i dont know the algorithm they are using but it is getting more obvious
the guide is here:
http://help.live.com/help.aspx?mkt=en-AU&project=a

Resources