Post to facebook with multiple cities target - facebook

I'm trying to post something with target parameters, and i can do that but specifying only one city. Is there any way to pass two or more cities?
I'm trying this way:
parameters.targeting = new {
countries = "some country",
cities = new [] { new { key = "city value" }, new { key = "other city value" } },
locales = "locale code"
};
But no success! How can i do this?

This is very unclear, but I am guessing you are just not formatting your array of cities correctly. See more here: https://developers.facebook.com/docs/reference/ads-api/targeting-specs/
I believe you should be using "name" instead of "key" for the cities, but again I really don't have enough information to go off of.

Specify key, radius & distance_unit. For key, see Targeting Search,
Cities. radius is a distance around cities, from 10 to 50 miles or 17
to 80 kilometers. distance_unit is mile or kilometer. Limit: 250.
Example: 'cities': [{'key':'2430536', 'radius':12,
'distance_unit':'mile'}]
Source: https://developers.facebook.com/docs/marketing-api/buying-api/targeting#location

Related

How to get the highest probability records from the collection. (Show most time searched)

I am creating application where it contains many dropdowns(more than 20), user can select any dropdowns to get the results. Every user login they are selecting dropdowns and get the results.
What I am doing is, storing all the selected dropdown values of each user(basically search string), planning to show your common searches, where they can just copy that search string and get the results.
Dropdown selection is mutiple
Intention is reducing the effort of selecting dropdowns if they have most common/almost common search they have. My dataset looks like below data stored in MongoDB.
This data is for single user, likewise it contains for all users.
{
"UserID": "123",
"SearchData": [
{
"searchText": "Area=[Bengaluru,Mumbai] Street_Number=[123,787] Locality=[Hebala,Electronic City] Branch=India",
"searchDateTime": "2020-04-03"
},
{
"searchText": "Area=Delhi Street_Number=[123,797,753,64] Locality=[Rajbhava,Redfort]",
"searchDateTime": "2020-04-04"
},
{
"searchText": "Region=[Asia,Europe] Branch=[India,Germany] Area=Delhi",
"searchDateTime": "2020-04-02"
},
{
"searchText": "Area=[Bengaluru,Mumbai] Team_name=[Team 1, Team 2] IsNewTeam=1 Region=[Asia,Europe] Branch=India",
"searchDateTime": "2020-03-04"
},
{
"searchText": "Region=United_States Branch=NewYork Team=[Team 1,Team 4] Locality=WTO",
"searchDateTime": "2020-04-04"
}
]
}
Expected Results like:
Your most searched/selected fields and Values are(Results for last 150 days searchText), Because I am planning not to keep Old data
1. Area=[Bengaluru,Mumbai] Branch=India Team 1 // Since this is common in many stings(Ex: Here in two strings)
2. Region=[Asia,Europe]
3. Branch=India
4. Team =Team 1
5. Area=[Bengaluru,Mumbai]
6. IsNewTeam == //If any common match found.
7. Area = //If any other common values found Expect the **Bengaluru,Mumbai**
//Ex : Dehli, Noida. This should come here
Any help would be very much appreciated.
Thanks in advance

Here geocoder API: retrieve route number based on coordinates

I noticed that I can retrieve route number based on coordinates using geocoding service. If coordinates are located outside the city, instead of street name geocoder returns route number (which is very useful).
Sometimes however route has multiple numbers - eg. "A4/E65/5". Unfortunately geocoder returns only one number - eg. "5". Is there any chance that geocoder can return full number?
Goeocder might not work here, have you tried getLinkinfo ?
e.g
http://route.st.nlp.nokia.com/routing/6.2/getlinkinfo.xml?app_id=DemoAppId01082013GAL&app_code=AJKnXv84fjrb0KIHawS0Tg&waypoint=45.79728,16.13712&linkattributes=all
With Geocoding use "locationattributes=addressNames". That will return many name variants including several languages and road numbers, e.g.
street: [
{
value: "A5",
language: "de"
},
{
value: "E451",
language: "de"
}
]

How to get audience_size in Interest plus Country query

Hi i'm still new in Facebook-ads-api I know this is a noob question,
I want to get the audience_size for the Interest in a specific country.
on the API sample it can only generate the whole world audience_size of an Interest
use FacebookAds\Object\TargetingSearch;
use FacebookAds\Object\Search\TargetingSearchTypes;
$results = TargetingSearch::search(
TargetingSearchTypes::INTEREST,
null,
'soccer'
);
// Sample Response
{
"data":[
{
"name":"Association football (Soccer)",
"id":6003107902433,
"audience_size":593326800,
"path":[
"Sports and outdoors",
"Sports",
"Association football (Soccer)"
],
"description":null
},
...other results...
]
}
In order to get the estimated audience, you can use the Reach Estimate.
You can see the documentation here: https://developers.facebook.com/docs/marketing-api/reference/ad-account/reachestimate/
Just pass the targeting object (which include the interest and the country) and get the result.

Omit response fields on Bing maps query

I'm looking for ways to reduce my bing maps query response size. For example - If I'm interested in the road distance between Seattle and LA, I'd query:
http://dev.virtualearth.net/REST/V1/Routes?wp.0=seattle&wp.1=losangeles&key=
(sorry, you'll have to use your own key)
... and that would give me something this (~1kB):
{
...
[
{
estimatedTotal: 1,
resources:
[
{
__type: "Route:http://schemas.microsoft.com/search/local/ws/rest/v1",
bbox:
[
34.053493,
-123.393781,
47.604151,
-118.242588
],
id: "v65,h-1259215200,i0,a0,cen-US,dAAAAAAAAAAA1,y0,s1,m1,o1,t4,w5D47BElTIPU1~ArgmUSjRxBABAADgAVva_j4A0~U2VhdHRsZSwgV0E1~~~,w9ecGAxFDffU1~ArgmUSgxwaIFAADgAQw_AT8A0~TG9zIEFuZ2VsZXMsIENB0~~~,k1",
distanceUnit: "Kilometer",
durationUnit: "Second",
routeLegs:
[],
travelDistance: 1827.815,
travelDuration: 58573,
travelDurationTraffic: 60478
}
]
}
],
...
This would look good, except expanding the routeLegs node gives me another ~23kB of data in the response - the full route - which I don't need. Anyone knows a way how to filter this out (either routeLegs or any of the underlying nodes?)
Thanks
You can now use the routeAttributes parameter documented here: https://msdn.microsoft.com/en-us/library/ff701717.aspx

algolia how to orderby string-value and geolocation

I am working on a prototype for a new product, need some help to figure out algolia feasibility. I did go through their documentation but couldn't find right answer. Any help appreciated.
Best example of our data is classified. In dataset we have geolocation(lat-lng) and category
[
{
category: 'retail_shops',
"_geoloc": {
"lat": 40.639751,
"lng": -73.778925
},
title: 'walget1'
},
{
category: 'retail_shops',
"_geoloc": {
"lat": 40.639751,
"lng": -73.778925
},
title: 'walget1'
},
]
Search Requirement
sortby category, selected category first, then all other in anyorder
sortby geolocation, this is secondary filter
We need to display all data in the system but selected category first and distance as secondary.
I am trying to do this is javascript, did find find search and searchForFacetValues methods but documentation is all-around. Any ideal how to achieve this? don't need code but general guidance will definitely help.
In order to do so, you can use a multiple-queries strategy, where you would have a query with a filter that matches the category, and then another query that matches all objects not in the category. In the query parameters you can then use the aroundLatLng field or the aroundLatLngViaIp field.
The following snippet should help you get a better understanding of how to achieve what you want:
const client = algoliasearch('ApplicationID', 'apiKey');
// these two values would be obtained from somewhere (like InstantSearch)
const query = 'walg';
const category = 'retail_shops';
const queries = [{
indexName: 'products',
query: `${query}`,
params: {
hitsPerPage: 3,
filters: `category:${category}`,
aroundLatLngViaIP:true
}
}, {
indexName: 'products',
query: `${query}`,
params: {
hitsPerPage: 10,
filters: `NOT category:${category}`,
aroundLatLngViaIP:true
}
}];
const searchCallback = (err, content) => {
if (err) {
console.error(err);
return;
}
const categorySpecificResults = content.results[0];
for (var i = 0; i < categorySpecificResults.hits.length; ++i) {
console.log(categorySpecificResults.hits[i]);
}
const geolocatedOnlyResults = content.results[1];
for (var i = 0; i < geolocatedOnlyResults.hits.length; ++i) {
console.log(geolocatedOnlyResults.hits[i]);
}
}
// perform the 2 queries in a single API call:
// - 1st query targets index `products` with category filter and geolocation
// - 2nd query targets index `products` with negative category filter and geolocation
client.search(queries, searchCallback);
You will find more information about how to use multiple queries on this page:
How to use multiple Queries
If you want a more fine grained control on the geolocation, like for instance defining a precision or a maximum range for the search, you can find more about these different features on these pages:
aroundLatLng: used when you want to define the geographical center of your query
aroundRadius: used to limit a search to a certain range around the center of the query
aroundPrecision: defines how precise the ranking has to be when it comes to distance.