Is what I see going on here, really going on here? - facebook-graph-api

I admin a couple pages on FB and we recently got hit by a supposedly fake page.
http://www.facebook.com/pages/Duke-St-Rollins/478408292178951
The page is supposedly a duplicate of this user:
http://www.facebook.com/DukeStRollins
However. When I entered this into Graph.facebook.com/478408292178951 I got this returned:
{
"name": "Duke St. Rollins",
"is_published": true,
"talking_about_count": 2,
"category": "Public figure",
"id": "478408292178951",
"link": "http://www.facebook.com/pages/Duke-St-Rollins/478408292178951",
"likes": 2
}
When I entered THIS into graph.facebook.com/Duke-St-Rollins I got this returned:
{
"name": "Duke St. Rollins",
"is_published": true,
"username": "DukeStRollins",
"about": "World famous troll and nemesis of teabaggers.",
"bio": "Press!\n\nhttp://blogs.phoenixnewtimes.com/bastard/2012/07/duke_st_rollins_on_jan_brewer.php \n\nhttp://madmikesamerica.com/2012/07/an-interview-with-duke-st-rollins/\n\nYouTube Channel\nhttp://www.youtube.com/channel/UC_xk6GQzKacHImYl3Vns4VQ\n",
"personal_info": "Follow me on Twitter ",
"talking_about_count": 6450,
"category": "Public figure",
"id": "204170076355643",
"link": "http://www.facebook.com/DukeStRollins",
"likes": 9459,
"cover": {
"cover_id": 261500633955920,
"source": "http://sphotos-a.xx.fbcdn.net/hphotos-ash4/s720x720/376513_261500633955920_779910133_n.jpg",
"offset_y": 92
}
}
If I am understanding how this works correctly, and did this right, does this mean the supposed 'fake' FB page is actually owned by the 'real' Duke?
If I have this wrong (and I hope I do), can someone please explain this to me slowly, like you are talking to a kid as I am TOTALLY new to doing the FB page stuff and until yesterday, never even knew about graph.facebook stuff.
Consider me a noob. Because I am. But I'd really like to know if what I think I am seeing, is what I fear.

No, they aren't the same. The former is a page/public figure. The latter is a user. You can tell them apart by their different IDs (478408292178951 / 204170076355643). They share the same name but can't share the same graph api address because hyphens are ignored (try http://graph.facebook.com/Duke-------------StRollins), which means DukeStRollins and Duke-St-Rollins are effectively identical.
This is in my opinion a glitch in the API: a query by name should be able to distinguish between these two resources, even if a hyphen - is the only difference between their names; that there is not just makes it easier for the spoofer to confuse people.
You've probably already seen this: https://developers.facebook.com/docs/reference/api/

In http://www.facebook.com/pages/Duke-St-Rollins/478408292178951 "Duke-St-Rollins" is just a dummy name created by the Facebook using the title name of the page. You can use anything in place of it to redirect you to the same page. The below links will all redirect you to http://www.facebook.com/pages/Duke-St-Rollins/478408292178951
http://www.facebook.com/pages/page-name/478408292178951
http://www.facebook.com/pages/page-title-name/478408292178951
http://www.facebook.com/pages/dummy-name/478408292178951
http://www.facebook.com/478408292178951 (note that here facebook recognizes 478408292178951 as the username for the page since the page didn't set it's username yet)
In the other page, http://www.facebook.com/Duke-St-Rollins "Duke-St-Rollins" is a username set by the page and hence it uses "dukestrollins" as the facebook graph node to recognize the page. (Note that in the username any dots or hypens will be removed automatically) All the links below redirect you to http://www.facebook.com/DukeStRollins
http://www.facebook.com/duke.st.rollins
http://www.facebook.com/dukestrollins
http://www.facebook.com/Duke-StRollins
http://www.facebook.com/204170076355643
http://www.facebook.com/pages/some-thing-here/204170076355643

Related

Azue Map Search: unique ID and normalized name

I use azure maps for cities autocomplete on my site.
I use this API method: https://learn.microsoft.com/en-us/rest/api/maps/search/getsearchaddress
Request: https://atlas.microsoft.com/search/address/json?params and parameters are:
query=mosco - I'm looking for Moscow
typehand=true
api-version=1.0
subscription-key=...my key...
Result is
{
...
results: [
{
type: "Geography",
id: "RU/GEO/p0/116970,
...
address: {
municipality: "Moscow",
countryCode: "RU",
freeformAddress: "Moscow"
}
},
...
],
}
Ok, it's Moscow.
But I have a few questions.
What is id? Doc say it is "property id". It is persistent? Moscow will always be "116970"?
How can I get normalize name of a city?
I can write "Москва" (Moscow in Russian) and it works and id is same, but names in the object address are different (Москва, Moscow).
If I write "mos" then id is same but address is "Moskva" (instead Moscow).
Can I get name of a geo object by id?
This is a unique id but is not guaranteed to be persistent. The main purpose of this id is for debugging purposes.
We are aware of the "en" issue and are updating the docs.
I sure this is a unique ID, but want proof from documentation :)
Problem solved by parameter language=en-GB now result always is "Moscow". I was misled by the manual when specified only en (it leads to error). https://learn.microsoft.com/en-us/azure/azure-maps/supported-languages

How to find plurals with Google Cloud Natural Language API

The Google Cloud Natural Language API can be used to analyse text and return a syntactic parse tree with each word labeled with parts-of-speech tags.
Is there a way to deturmine if a noun is plural or not?
If Google Cloud NL is able to work out the lemma then perhaps the information is there but not returned through the API?
Update
With the NL API's GA launch, the annotateText endpoint now returns a number key for each token indicating whether word is singular, plural, or dual. For the sentence "There are some cats here," the API returns the following token data for 'cats' (notice that number is PLURAL):
{
"text": {
"content": "cats",
"beginOffset": -1
},
"partOfSpeech": {
"tag": "NOUN",
"aspect": "ASPECT_UNKNOWN",
"case": "CASE_UNKNOWN",
"form": "FORM_UNKNOWN",
"gender": "GENDER_UNKNOWN",
"mood": "MOOD_UNKNOWN",
"number": "PLURAL",
"person": "PERSON_UNKNOWN",
"proper": "PROPER_UNKNOWN",
"reciprocity": "RECIPROCITY_UNKNOWN",
"tense": "TENSE_UNKNOWN",
"voice": "VOICE_UNKNOWN"
},
"dependencyEdge": {
"headTokenIndex": 1,
"label": "DOBJ"
},
"lemma": "cat"
}
See the full documentation here.
Thanks for trying out the NL API.
Right now there isn't a clean way to detect plurals other than to note that the base word is different than the lemma and guess whether it's plural (in English, perhaps it ends in an -s).
However, we plan to release a much better way of detecting morphological information like plurality, so stay tuned.

Facebook graph API: get the "subcomments" in a tree of a discussion

I am trying to download a Facebook discussion using the graph API. The problem is: the discussion is located in a page, and in a tree-style manner, meaning that there are two types of comments: "main" comments, to the first message, and "subcomments" to the main comments themselves.
It seems that the graph result only shows the "main" comments and doesn't show the subcomments. Here's an example of a comment it returns:
{
"id": "53526364352_1574091",
"can_remove": false,
"created_time": "2014-02-05T10:46:37+0000",
"from": {
"name": "Main commenter",
"id": "5345353"
},
"like_count": 163,
"message": "I am a main comment",
"user_likes": false
},
There is no link or whatever to the subcomments of this main comment (and there are many).
Is there a way to get the subcomments?
If 10101140614002197_8831228 is an ID of a root comment, then you can check for subcomments/replies by requesting COMMENT_ID/comments.
For example:
the root comment: http://graph.facebook.com/10101140614002197_8831228
the subcomment: http://graph.facebook.com/10101140614002197_8831228/comments
this root comment has no subcomments so the data list is empty: https://graph.facebook.com/10101140614002197_8831286/comments
You can use field expansion (curly parenthesis in url) to get nested data
http://graph.facebook.com/{object-id}/comments?fields=id,message,comments{id,message,comments{id,message,comments}}
More info here in the section labeled Nested requests (a.k.a. field expansion).
If you want to traverse and flatten the tree, you can do this:
def get_all_comments(post_or_comment_id):
next_ids = [post_or_comment_id]
results = []
while next_ids:
next_id = next_ids.pop()
comments = get_comments_from_facebook(next_id) # Facebook API call
results += comments
next_ids.extend(c["id"] for c in comments)
return results
Make sure to add parent to the API call so you can replicate the tree.

Regex find and replace all words

Reg-ex always confuses me, plus super simple syntax's are hard to Google. I am using reg-ex here strictly with find and replace no need for any languages to do some reg-ex just want to save time editing a lot of data :)
I have a huge json file, these are only two pieces of data, but it's good for this example.
[
{
name: 'John',
team: 'Wolves',
team_id: 1,
number: 24
},
{
name: 'Kevin',
team: 'Rockets',
team_id: 1,
number: 6
}
]
Inside my json I need to put double quotes over pretty much every key:value pair, numbers are optional.
I need to get rid of the single quotes, then put double quotes over everything.
Final result looking like this.
[
{
"name": "John",
"team": "Wolves",
"team_id": "1",
"number": "24"
},
{
"name": "Kevin",
"team": "Rockets",
"team_id": "1",
"number": "6"
}
]
Again, numbers are optional but it would be nice to know how to double quote those.
Extra: I vaguely remember doing something like this awhile back, but can't find where I found that information. This would be a nice reference. Does anyone have any good links to the basics of regex, I just want to save time when working with a lot of data. Thanks.
Try something along the lines of this:
(\w+):\s*('?)([^']+?)\2(?=[\n,]) and replace by "\1": "\3"
Demo: http://regex101.com/r/pX9xX6
Edit:
Just tested in Sublime, seems to work fine.
Well, the exact syntax depends on the tool. If you were using vim, for instance:
:%s/'\([^']*\)'/"\1"/g
and
:%s/^\([ ^I]*\)\([^ ^I]*\):/\1"\2":/
would probably do the trick, although you'd want to do a manual check for any quoted quotes..

changing ember RESTAdapter get request

at the moment, when ember is asking for child data through the rest adapater, it makes a GET request with the following options:
http://localhost/orders?ids%5B%5D=0x0000000000000386&ids%5B%5D=0x00000000000003a4&ids%5B%5D=0x00000000000003cf&ids%5B%5D=0x0000000000000631&ids%5B%5D=0x0000000000000639
which equates to parameters of
ids[]:0x0000000000000386
ids[]:0x00000000000003a4
ids[]:0x00000000000003cf
ids[]:0x0000000000000631
ids[]:0x0000000000000639
I was wondering if there was a way of changing that to be either
id1:0x0000000000000386
id2:0x00000000000003a4
id3:0x00000000000003cf
id4:0x0000000000000631
id5:0x0000000000000639
or
{ids: [{"id":"0x0000000000000386"},
{"id":"0x00000000000003a4"},
{"id":"0x00000000000003cf},"
{"id":"0x0000000000000631"},
{"id":"0x0000000000000639"}
]}
I have solved this by using the "links" option in the data.
Within the json returned at the higher level , include the links
{customers : [
{name": "foobar inc",
"links": {"orders:/customers/181/orders"}
}]
}
so now when ember tries to get the orders of a customer, it will make a json request to the url specified in the links
this works really well for me. It also has the advantage of not having to load all children in as either ids[] or sideloading.