How do you access a user's languages using the Facebook GRAPH API? I don't see it anywhere in the permissions and I can't find it any other way. If a user lists that they speak Spanish or French, how can I find this?
You can get the languages from https://graph.facebook.com/me .
If you are looking for user locale as #chacham15 mentions then its from locale variable . See https://graph.facebook.com/harikt .
You can try http://developers.facebook.com/tools/explorer?method=GET&path=me and see it in action.
Update :
The permission user_likes is need to access the languages array .
[languages] => Array
(
[0] => Array
(
[id] => 105692839465644
[name] => Malayalam
)
[1] => Array
(
[id] => 106059522759137
[name] => English
)
)
Hope this solves your issue.
What I do is to check the user locale and I assume that he speaks that language, for example:
$locale_f=$parsedJson->locale;
$lang1=explode("_",$locale_f);
if ($lang1[0]=="es") $lang1="espagnol";
if ($lang1[0]=="en") $lang1="anglais";
if ($lang1[0]=="it") $lang1="italien";
if ($lang1[0]=="pt") $lang1="portugais";
if ($lang1[0]=="fr") $lang1="francais";
You should display the language based on the locale variable which is part of the user table. You will get a value that is something like en_US (us english), en_GB (british english), or fr_FR (France french).
Related
I am trying to do something that would go something like this below. I am trying to determine the language of a job description so my assumption is that if there is not a div class or h2 for it already, I would have to review the job description to find keywords that represent each language (such as 'and'), that I could preferably build some kind of directory. How could I do something like below but in python?
P.S. I am a complete beginner to python and code in general, so simple terms if possible. This is my assumption of framework structures if I made one up myself. I hope it is easy to understand. The purpose is for scraping job offers from company pages.
## Last one is the language. I would need to to first review the language of the text
if there's a tool to do that automatically
## or I could set up a review job description and create a keyword list for each
language.
Of course it is easier if they have this part on the job offer page.
language = joblink.get('h2', class_ = language)(language.redirect)
#keep reading for this directory
return if True #if the page has this
if False: #if the page doesn't have this
language = jobdescription.search(languagetxt.review & language.review):
if duplicates.remove
if multiple(language.redirect)
#'languagetxt.review' Directory
' und ' => 'German'
' and ' => 'English'
' et ' => 'French'
#'language.review' Directory
'German' => 'German'
'Native German' => 'German'
'Fluent in German' => 'German'
#'language.redirect' Directory
'English and German' => 'German and English'
'German, English' => 'German and English'
#expect it to read something like (German, English, English) = 'German and
English'
because of multiple
# result would look something like
# German and English
I'm playing around w/ the /me/music.listens endpoint of Graph API and I have it working just fine. Except I can't seem to figure out how to get actual artist info to come back. I see the song and even the album (though that seems a little inconsistent too). But never any artist info.
Check the developer explorer here: https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Fmusic.listens
No artist info. Is this just not returned? I can't see how to specify this in a fields param list. FB's documentation of the actions is spotty at best so I figured I'd try here.
Thanks!
I've figured out a work around. It doesn't look like Facebook actually returns artist info. So you have to use the Spotify Lookup Service (http://developer.spotify.com/technologies/web-api/lookup/).
To break it down a little further, you start by pulling the music.listens feed from FB and you'll get info that looks like:
(
[song] => Array
(
[id] => 381659191902248
[url] => http://open.spotify.com/track/**2Vv27Gc5k5GgGW9jgtj1CS**
[type] => music.song
[title] => Follow Through
)
)
From there, you need to grab the bolded track ID.
Lastly, fetch the song metadata with this call to Spotify: http://ws.spotify.com/lookup/1/.json?uri=spotify:track:2Vv27Gc5k5GgGW9jgtj1CS
You'll be returned the album name, artist info, etc.
If someone knows a better way, lemme know!
You can retrieve artists informations on graph API with the song id :
https://graph.facebook.com/song_id?fields=data{musician}
ex : https://graph.facebook.com/697975930266172?fields=data{musician}
Old question I know, but you can retrieve related information such as both the song title and artist title in the same request using Graph API's 'field expansion'.
For example - Last 10 songs
me?fields=music.listens.limit(10){data{song{title,id},musician{id,title}}}
To retrieve more information from either the song or musician entities just tweak the fields requested.
Note, this requires user_actions.music permission
So I want to get linked typed post from users home stream
But I want it to have specific url like "where link url = example.com"
As a result I will have a data of my friends who had shared that link.
First I tried querying the home with
https://graph.facebook.com/me/home?q=example (worked but partly, only old posts)
Then I did:
friends_id = [Get all ids]
[foreach friends_id as id]
make facebook api call to that id
get all links that user had shared
[foreach links as link]
filter all of them for a specific link
[if shared the link] save user to an array
And that was really slow! 6 sec for a person
And lastly I tried to get it with
fql using stream and stream filter. The problem with that I can get posts but I can't query what is that link
Printing the array gives me:
[post_id] => **********
[actor_id] => *******
[target_id] =>
[message] =>
[action_links] =>
[type] => 80
So how can I achieve my goal of having an array of data of my friends who had shared that link?
Sorry, only possible by using
friends_id = [Get all ids]
[foreach friends_id as id]
make facebook api call to that id
get all links that user had shared
[foreach links as link]
filter all of them for a specific link
[if shared the link] save user to an array
I am able to post to a users feed using a URL from my app, for example:
https://graph.facebook.com/USER_ID/feed?
link=https://developers.facebook.com/docs/reference/dialogs/&
picture=http://fbrell.com/f8.jpg&
name=Facebook%20Dialogs&
caption=Reference%20Documentation&
description=Using%20Dialogs%20to%20interact%20with%20users.&
message=Facebook%20Dialogs%20are%20so%20easy!
According to the documentation here: https://developers.facebook.com/docs/reference/dialogs/feed/ it is possible to add "actions" which appear next to the Like and Comment buttons under each post. The documentation states the actions must be in a JSON format with object with keys name and link
Well, you could add actions parameter. If in PHP then you could do like:
'actions' => json_encode( array(
'name' => 'Some sample link example',
'link' => 'http://something.com/test/'
)),
Did you mean something like that.
Hope it helps
I have my app posting a link to the user's wall if they have given it permissions, but it ignores the picture, name, and caption values I pass along with it.
HTTParty.post("https://graph.facebook.com/#{#sponsorship.fbid}/links", :query => {:access_token => URI.escape(#access_token), :link => URI.escape(request.env['HTTP_HOST']), :picture => URI.escape("#{request.env['HTTP_HOST']}/images/fb_post/after_donation.jpg"), :name => URI.encode("Click here"), :caption => URI.encode("This is the caption")})
Any help is appreciated, thanks.
Think you might need to be using
https://graph.facebook.com/#{#sponsorship.fbid}/feed
instead of
https://graph.facebook.com/#{#sponsorship.fbid}/links
It's probably taking those values from the open graph meta tags on the link target rather than the ones you provide at post time. Not sure if that's supposed to be happening but you should check if your link has the correct tags.
https://developers.facebook.com/docs/opengraph/ is the docs and https://developers.facebook.com/tools/debug will show you what markup is detected on your page