I am using Facebook Graph API to search facebook POST with location parameter. I am using the below code.
string url = string.Format("https://graph.facebook.com/search?q={0}&type=post&limit=10&location=Newark,NJ,US", txtSearch.Text);
WebClient web = new WebClient();
string xml = web.DownloadString(url);
The above code works fine witout any error, but it doesnt look like it is considereing location parameter.
Is it possible to add any location paramter to the search query fetching Facebook Post?
location parameter can be in form of actual location string (e.g. Los Angeles, CA,US) or GeoCode value ?
Facebook does not support location por "post" search using API
You can't do it for post but you can search a place by location with a geocode:
https://graph.facebook.com/search?q=coffee&type=place¢er=37.76,-122.427&distance=1000&access_token=...
Related
I'm using Instagram Mentions API and was able to obtain FB media_id for couple Instagram posts.
I need media_id to get post content via /user/mentioned_media. Unfortunately that endpoint does not provide ig_id or shortcode or permalink which I need.
Is there a way to get Instagram Post URL with FB Graph API media_id?
It seems like you can get media metadata (and all comments/replies) when someone #-mentions you in a non-owned-media comment by using a query like below.
You would use your own instagram business account id for the first number (the path component), and you'd use the comment_id you received from the webhook comment-mention notification as the second number:
/12345678901234567890?fields=mentioned_comment.comment_id(9876543210987654321){id,text,username,timestamp,media{id,media_type,media_url,permalink,username,like_count,comments_count,comments{id,text,username,user{id,username},like_count,timestamp,replies{id,text,username,user{id,username},like_count,timestamp}}}}
Yes, there is a way you can get Instagram post URL associated with a media if you know the media id.
You can also get more information (all its fields and edges) on media. See the docs here
You can get the Instagram post URL by making a GET request to /{ig-media-id}
Sample Request:
GET https://graph.facebook.com/v15.0/{{media_id}}?fields=permalink, shortcode&access_token={{ACCESS_TOKEN}}
Sample Response:
{
"permalink": "https://www.instagram.com/p/Clxsi5Pol2_/",
"shortcode": "Clxsi5Pol2_",
"id": "17xxx59557977xxx"
}
The value of the permalink is the valid public URL for the post.
You can also use the shortcode returned to construct the URL by concatenating the shortcode to https://www.instagram.com/p/.
I've been playing around with the Facebook graphs api for a while, and to the best of my knowledge you shouldn't be able to get a Facebook user's id from their username.
I then came accross stalkscan.com and note that they do just that. You provide a Facebook url and the resulting queries contain that usernames profile id.
How can I acheive a similar result with or without the graphs api?
You can get a facebook user id by using the following endpoint:
URL /?id={url}
{url} represents an external URL as it relates to the Facebook social graph - shares and comments from the URL on Facebook, and any Open Graph objects associated with the URL. (e.g. a user, a page...).
With Python, you can use something like this:
import requests
USER_URL = '' # your link
ACCESS_TOKEN = '' # your credentials
params= {'id': USER_URL,'access_token': ACCESS_TOKEN}
fb_graph = "https://graph.facebook.com/v2.7/"
r = requests.get(fb_graph, params=params)
fb_id = r.json().get('id')
print('Facebook User ID: %s' % fb_id)
Full documentation of the graph API is available here.
Before version 2.1 i was using fql to get user public information using the following code.
"https://graph.facebook.com/fql?q=select uid,name,current_location from user where uid = xxx"
Then i would parse the country, state and city from the response.
without fql we are using location field which leads to a page and the page gives longitude and latitude.
How do i get the country in v2.2 (The name or country code)
Thanks
You can easily get the location with Graph API using /user
refer to below link.
https://developers.facebook.com/docs/graph-api/reference/v2.2/user
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=me%3Ffields%3Dlocation&version=v2.2&
I'm logged in using to my own Application using C# Facebook SDK and I can read/write/delete all data I need.
However for validation purposes I'd like to get AppID that I'm currently using (the one I used when generating login Uri) based on existing valid Access-token and Facebook.FacebookClient object.
In a similar way like in Facebook PHP SDK: $appId = Facebook->getAppId();
My access token is not like string.Concat(appId, "|", appSecret)
If I use Facebook C# Sdk I may use following code to retrieve appID I used when loging in - if at the moment I have in memmory only AccessToken available:
string myAccessToken = "...";
FacebookClient fc = new FacebookClient(myAccessToken);
IDictionary<string, object> resultContainer =
(IDictionary<string, object>)fc.Get("/app");
string retrievedAppID = resultContainer["id"] as string;
The same result can be obtained directly from Graph Api Explorer via:
https://graph.facebook.com/app
If desired Facebook application is selected at top right part of the Graph Api Explorer page.
In the Facebook C# SDK, there is no where that access_token parses(or decoded).
Naturally, Facebook C# SDK api, it takes appId from Web.Config through the FacebookSettings class.
access_token as string property of FacebookSignedRequest class.
So you may follow this link to do it yourself: https://developers.facebook.com/docs/authentication/signed_request/
You should be able to get the AppId like this:
var appId = Facebook.FacebookApplication.Current.AppId;
I want to create a flash Facebook application in which, after pressing a button, the user will be able to browse his/her photo albums and choose a photo. How should i do that? What will be the code under the button to gain authentication from any user using this application?
Thanks.
I am currently writing a facebook application for a university assignment that will allow the user to do everything you can do in facebook, but via the flash player window. You will need a few basic things happening in order to do it.
User log in and authentication - this must be done via Facebook - using OAuth authentication, and meeting all of facebook's security policies
register the application with facebook
Use the Graph API (facebook's developer's toolkit) to get the necessary functions that will communicate with facebook via flash.
In Flash itself you will use a bunch of URLRequest functions to send out to FB for information, then you will need to retrieve that data responses and store them to variables (extracting data with a few lines of code is easy, something like this;
//initialise variables
public var photoURL:String;
var Request:URLRequest = new URLRequest("http://www.whatever the url for the graph api service you are using which is founf from FB");
//that ^^ will send off a request for the url, you then want to use the returned data by registering an event handler like this below
functionName.addEventListener(onComplete, completeHandler);
functionName(event, EVENT)
{
var loader:URLLoader = new URLLoader(Request);
var data:XML = new XMLData(load.loader); //i think this is right but not 100% sure, fiddle with it
//then you want to extract the data that is returned, for example, extracting xml data from a rest request works by hitting data from the xml by specifying a path to the object you want. an example of xml is this <rsp stat="ok"><photos ......more code="morecode"><photo url="url of photo"></photo</photos> so you can hit the url in that example like this;
photoURL = data.photos.photo.#url; //this line will grab the photo url for you, allowing you to dynamically create an array and assign photos to the flash stage according to the url you get
}
this is fairly advanced stuff and I am assuming that you have some decent knowledge on AS3, XML, and the FB API, if you need more help just reply