How to make a Facebook search request to find Locations - facebook

I use Facebook C# SDK. I try to make a Facebook search request to retrieve locations without success.
I don't know all the parameters which can be used in a "search" request.
I use this code:
Dictionary<string,object> searchParams = new Dictionary<string,object>();
searchParams.Add("q", "Orange");
searchParams.Add("type", "place");
searchParams.Add("country", "France");
FacebookClient fbClient = new FacebookClient(token);
var searchedPlaces = fbClient.Get("/search", searchParams);
I receive a response with some places everywhere in the world not only in France!!
The filters "category" and "country" have no effect.
Which parameters can be used in the request ? Where find the parameters list for a search request?
How to fix parameters "category", "country" and what write in the parameter "q"?

From the Documentation:
The example search for places is given as https://graph.facebook.com/search?q=coffee&type=place&center=37.76,122.427&distance=1000 - you'll need an access token but otherwise that works fine for me; the response shows Coffee shops centered around those coordinates
{edit}
The only search options are
q for a text based query
center (with coordinates) and distance to specify the approximate location
Both of the above

Related

Bing Maps throwing "Invalid Geocode" error on street intersection that it is able to get the Latitudes and Longitude from

I am currently working on a project that involves calculating Duration matrices from a collection of thousands of addresses using NEO4J and Bing Maps API. Since the data is sensitive, we're going to use the mock address (which actually produces the same issue I'm describing) '72ND & DODGE, OMAHA, NE 68132' to represent the format intersection addresses are being sent to Bing Maps API using their keys and basic url requests.
To preface this: the issue isn't with my code (which is also sensitive data), as all my code is doing is sending one url string of the above format plus the authorization key to Bing Maps and awaiting a response that contains the duration data of the trip. My issue is Bing Maps being seemingly unable to handle or work with intersections of streets to calculate distances/durations from other locations. When I throw these addresses into Bing/Google Maps in the web browser, they are able to be found and calculated in the exact same format as the above example.
I start off my program checking if an address exists/is valid by having it find the latitude and longitude of each address, so for the example '72ND & DODGE, OMAHA, NE 68132' it found: Lat: '41.259690' and Long: '-96.023770'. If it is unable to find the Lat/Long of an addresses, then it throws the 'Invalid Geocode' error, but in this initialization context it means the address does not exist, or is poorly formatted, which makes sense and is why I did this for the initialization phase.
However, if I go to use '72ND & DODGE, OMAHA, NE 68132' for any duration calculations between other addresses, it throws the 'Invalid Geocode' for '72ND & DODGE, OMAHA, NE 68132' over and over again with no explanation on why even though it passed the Lat/Long check. I'd also like to mention that this issue isn't consistent, as some intersections do not work while others do, but there is no consistency in knowing which ones will or will not work. Thus, I am ultimately wondering if Bing Maps is unable to calculate certain addresses no matter their formatting or whatnot.
Be sure to encode your query before putting it into the URL. Especially when you have & in your query since it would then break your query up, thinking you were asking just for 72ND and the rest of your query is query string parameter name. This is documented in the best practices section here.
In Java you can encode the query parameter like this:
String baseURL = "https://dev.virtualearth.net/REST/v1/Locations?key={BingMapsKey}&query=";
// query string
String query = "72ND & DODGE, OMAHA, NE 68132";
// URL encode query string
String encodeStr = URLEncoder.encode(query, StandardCharsets.UTF_8.name());
// final url
String url = baseURL + encodeStr;
Here is an example of how your query URL should look:
https://dev.virtualearth.net/REST/v1/Locations?key={BingMapsKey}&query= 72ND%20%26%20DODGE%2C%20OMAHA%2C%20NE%2068132

I can not get the number of followers on a page

I'm trying to get the number of followers on a page. That is, obtain the number that appears in the portal as: "1363 people follow this"
I am trying to make the call as follows:
Dim urlSocialAnalitics As String =
String.Format ("https://graph.facebook.com/{0}/friends?summary=total_count&access_token={1}", pIdFanPage, pToken)
But it does not work. It's a problem for me.
I have also tried with this url:
urlSocialAnalitics = String.Format("graph.facebook.com/v2.6/{0}?fields=fan_count&access_token={1}", pIdFanPage, pToken)
But this gives me the number of Likes and not of Followers
I have read the documentation:
https://developers.facebook.com/docs/graph-api/reference/page/
But I do not see anything about it.
What is the correct call?

How do I list cards for a specified customer using Balanced API?

I am using PHP to try to get the card from Balanced.
I can get all the cards using
$marketplace = Balanced\Marketplace::mine();
$cards = $marketplace->cards->query()->all();
I can look though the $cards array and in each card object I find a values like this
uri : /v1/marketplaces/TEST-MP4K6K0PWGyPtXL4LZ42sQSb/cards/CC5N3HHUDrAyvhNwQOoUd3UX
this appears to be formatted as
"/v1/marketplaces/MARKETPLACE ID/cards/CARD ID"
However I only want the cards for a specific customer so I tried
$customer = Balanced\Customer::get("/v1/customers/CU6vs1tjxBtifgTuzKjCGtVS");
$cards = $customer->cards->query()->all();
Now when I look thought the card object the format of the uri has changed
uri : /v1/customers/CU6vs1tjxBtifgTuzKjCGtVS/cards/CC5N3HHUDrAyvhNwQOoUd3UX
So it gives the uri as
"/v1/customers/CUSTOMER ID/cards/CARD ID"
Question, can I use this customer based uri for all card functions such as charging and deleting?
Or, if I have to use the marketplaces format do I rebuild the URI (which balanced warns against) or is there some why I can get the uri in it's proper format?
You can use either of those uri's. They are just using different endpoints, but will result in the same successful transactions.

Google MAP Api http Request

I am making an iphone app that enables users to search for a city/town/countries/states by keying in texts in a UISearchbar, I managed to get the reply from google via JSON. It works ok, but I have some unexpected replies for certain places.
When I search for, say, "Vietnam", "China", "Malaysia", "Indonesia" it gives 0 results.
But when I search for, "Singapore", "Cambodia", then, it gives a result fine.
I don't get it, why does some countries aren't available as the search results?
Thanks.
Codes: The http request I sent is something like:
http://maps.google.com/maps/geo?q=%#?output=json
The %# is a searchBar.text formatter.
So if i type Indonesia, basically the request becomes:
http://maps.google.com/maps/geo?q=Indonesia?output=json
Instead of using an undocumented output of maps.google.com, you should try using the Geocoding API:http://code.google.com/apis/maps/documentation/geocoding/#JSON Your query would be something like:
http://maps.googleapis.com/maps/api/geocode/json?address=indonesia&sensor=false

Facebook - obtain location /places ID via location name

I'm able to return a location's details by sending a query via the graph api with the location's ID, however I'm looking to achieve the reverse - effectively find location id by sending a request containing the location name (city, state etc). Is this possible?
This is possible under a few different approaches. You can either search using long / lat positions and put the place name into the query. This search will search places only.
Do the following
https://graph.facebook.com/search?q=ritual&type=place&center=37.76,-122.427&distance=1000&access_token=mytoken.
This will return ritual coffee.
Another way is to search through facebook pages using the following
https://graph.facebook.com/search?q=ritual%20coffee&type=page&access_token=mytoken
This way is more difficult as you will obviously need to parse the list in more detail.
You also can use the place sdk from facebook:
compile group: 'com.facebook.android', name: 'facebook-places', version: '4.30.0' // For latest version, see https://developers.facebook.com/docs/android/
and then:
PlaceSearchRequestParams.Builder builder = new PlaceSearchRequestParams.Builder();
builder.setSearchText("Cafe");
builder.setDistance(1000); // 1,000 meter maximum distance.
builder.setLimit(10);
builder.addField(PlaceFields.ID);
GraphRequest request = PlaceManager.newPlaceSearchRequestForLocation(builder.build());
request.setCallback(new GraphRequest.Callback() {
#Override
public void onCompleted(GraphResponse response) {
// Handle the response. The returned ID in JSON is the placeId.
}
request.executeAsync();
If I understand your question correctly you can use fql:
https://api.facebook.com/method/fql.query?query=QUERY
where query should be something like this:
select page_id from place where name = ;
Here is a page for your refrence:
http://developers.facebook.com/docs/reference/fql/place/