Load the creative information with the adgroup not just the creative id - facebook-ads-api

I am trying to figure out if anyone has a better way to load facebook adgroups with the creative information. So far the only way I have been able to find is, load all the adgroups using the api point here: /act_{account_id}/adgroups
I pass the fields 'creative' to get the id, then I have to load all the creatives and pull the data i want.
I can not seem to find a way to filter the creatives to only return the ones I want. Returns all the creatives that ever existed in the account. Seeing that some accounts have 25k+ creatives this is an issue.
The creative endpoint is: '/act_{account_id}/adcreatives/'
https://developers.facebook.com/docs/marketing-api/adcreative/v2.3
Ideally, it would be amazing if there was a way to just load the creative information directly from the adgroup listing.
I am just looking for a few fields in the adcreative url_tags and object_story_spec

You can use nested request for that. In your case the URL would look like this
/v2.3/<adgroup_id>?fields=creative{url_tags,object_story_spec}

Related

Alternative to spring-mobile

I have a requirement where in all controllers I need to understand device type (desktop, mobile, tablet) and based on that I may need to send request to a different view. Right now, I have littered my controllers with duplicate code that does following:
Get User-Agent from HttpServletRequest
Find device type by matching User Agent string containing multiple pre-defined keywords in an array.
Use if/else statement to forward request to different view based on detected device type
To fix this I found out that spring-mobile is able to help with this. But unfortunately it looks like this project is abandoned. I am looking for a better alternative as a dependency or maybe a better design pattern to handle this problem.

How to keep track of some user data without displaying it in the URL

I'm developing a web app with two languages, German and English. I have implemented searching on my webpage, and I want to keep track of the user's locale when searching.
How can I achieve this:
http://localhost:8080/user/search?search=pax?lang=de
instead of:
http://localhost:8080/user/search?search=pax
In my form I have:
action="/user/search"
I tried
action="<spring:message code="user.search.movie.link"/>
user.search.movie.link = /user/search or /user/search?lang=de
but it doesn't work.
Putting information in URL parameters is good in some cases*, but probably not this one. It seems likely that a user chooses their language setting once, around login time, and then rarely if ever changes it. Or it might even be set automatically. If so, language is something you might want to store in the user's session, or a persistent store like a database if you're using one. You seem to be using Spring, and I don't know a lot about their session handling, but their docs are at https://docs.spring.io/spring-session/docs/current/reference/html5/.
*: for more on this, you might want to read up on the differences between GET requests and POST requests (here's one of many SO posts on the topic). The most relevant part for you is that GETs are the ones that have visible parameters in the URL, but there are lots of other reasons to use one over the other.

Is there a way to find all the relations that exists between two entities?

I need to populate an ontology in the domain of Music Artists. To get an understanding of the domain which I should populate, I need to find out,
1) All the possible objects related to the particular artist. (Song, Album, Movie etc.)
2) All the possible relations between this celebrity and the object. (Singer Object).
Is there any way to do this manually or through Google API?(I tried this manually by giving this on the google search bar. But it is a hard task to do it manually. Though if there is a way to speed this up, it would be sufficient at the moment.)
What you need is a way to query the web which will combine results from various websites and web pages and present a combined and coherent result to you based on your query. Currently this cannot be done for the web in general. However, the semantic web is an area of research that is trying to achieve exactly that.
Using semantic web technology it is possible to do such queries for parts of the web. DBpedia is a prominent semantic web project that aims to enable arbitrary queries across Wikipedia. DBPedia provides a live end-point that you can query using SPARQL. Referring to DBpedia will give you a brief overview of how this all fits together.
Accessing the live end-point you can run the following SPARQL-query that will give a list of musicians. Clicking on the links in the result page will provide you with more information on each musician.
SELECT ?subject
WHERE {
?subject a dbo:MusicalArtist .
}
Good luck!
Found a method to retrieve entities related to a particular object through google knowledge graph API.
Google Knowledge Graph API

how to implement Multi-Tenant functionality in asp.net-core

I have an Asp.net Core application I want to be able to allow multiple/ different Tenant(Client)to access the same application but using different url's. I have common database for all tenant(client).
So It is the main part I want to host my application in a domain say... www.myapplication.com then allow different Tenant(client) to access the same application using
1.www.TenantOne.myapplication.com
2.www.TenanatTwo.myapplication.com.
3.www.{TENANCY_NAME}.myapplication.com
I can't find any info on how to do this and I'm stuck.
How to do it? Please provide the code. Thanks.
As Saravanan suggested these types of questions don't belong here on SO. To get you started, I suggest you start looking if there are any frameworks such as SaaSKit available to add a multi tenancy layer to the pipeline.
The essential part is to know where each request comes from. Using subdomains is a good way to achieve that and middleware is a good place to 'identify' your tenant. You could have a database to persist the tenants but the implementation is entirely up to you. I also wrote a little article on the subject. Although it isn't ASP.NET Core, the principles still apply.
The approach I believe you are looking for is similar to the article at the url below.
https://dotnetthoughts.net/building-multi-tenant-web-apps-with-aspnet-core/
In it, the author splits the requesting URL into an array of strings delimited by the dot in the address. The variable 'subdomain' is then set to the first element of that array. In your question, it looks like you may want to use the second element in the array, but you get the idea.
var fullAddress = actionExecutingContext.HttpContext?.Request?
.Headers?["Host"].ToString()?.Split('.');
var subdomain = fullAddress[0];
//do something, get something, return something
How you use this data is up to you. The author of the article created a filter attribute, but there are many possibilities such as passing the tenant name as a parameter to a service function.
Sorry,you have to get something to start with and then come back for the people to help you with.
I would say that this is all of a domain based wild card mapping and change in your authentication logic to get the tenant id from the URL. Once you identified the tenant, you just login and then take it forward. Like you might be having a database with the tenant details like
tenant1 | tenant1.company.com | guid-ofthe-tenant | etc...
Once you get the URL, you lookup in the above table and get the tenant code and then you choose the login mode and then proceed.
In case you have tried something yet, we would be happy to point you if it does not work yet.

Filter the form choices visible in the browseable API

I am using a filter to apply object level permissions to a collection. Resources in a second collection have a many-to-many relationship with the first. On the browsable API, when creating resources in the second collection, the user is presented with a list of resources from the first to link it to. However, this list is not filtered, so the user can see values that they should not be able to see.
I've poked around the documentation and source a bit and I cannot see a way to add filtering to the queryset that generates the choices without overloading or modifying a bunch of code to pass the request data down (probably removing some of the collection specific data on the way) and then apply the filters.
Is there a better way to achieve this?
Currently there's nothing to support this out of the box. Pull requests are always welcome. If it's something you want to work on you may want to either open a ticket on GitHub or hit up the mailing list to discuss it first.

Resources