I would like to load LinkedIn Ads data into my Power BI report.
Are there any easy approach for accessing the data?
Thanks in advance!
there are few options to connect Linkedin ads to Power bi:
1- Downloading the csv files and importing to Power bi.
2- Creating an app in Developper.linkedin.Com, and getting the an API URL.
Then in Power bi you press on Get data -> from web and then add your API URL in the box that appears.
3- This is probably the easiest option which is to use a third-party connector, but you will still need to create an app in Developper.linkedin.com, and use your client's id and client's secret key to be able to access your data.
Turned out that you need to write or a custom connector by following the docs:
https://learn.microsoft.com/en-us/power-query/samples/trippin/readme
Or you need to write in M your custom code for accessing the API:
let
GetAccessToken =
let
TokenEndpointUrl = #"TokenEndpoint" & "?client_id=" & #"AppID" & "&client_secret=" & #"AppSecret" & "&grant_type=client_credentials",
TokenRequestResult = Json.Document(Web.Contents(TokenEndpointUrl)),
AccessToken = TokenRequestResult[access_token]
in
AccessToken,
GetData = (Url) =>
let
FinalResult = if Url = ""
then
{}
else
let
Result = Json.Document(Web.Contents(Url,[
Query=[
date_preset="lifetime",
level="ad",
fields="impressions,spend,account_id,account_name,campaign_id,campaign_name,adset_id,adset_name,ad_id,ad_name",
time_increment="monthly"]
])),
NextUrl = Record.FieldOrDefault(Result[paging],"next",""),
CombinedData = Result[data] & #GetData(NextUrl)
in
CombinedData
in
FinalResult,
#"Data Endpoint" = #"DataEndpoint",
AccessToken = GetAccessToken,
#"Calls the functions and makes the result" = GetData(#"Data Endpoint" & "&acces_token=" & AccessToken)
in
#"Calls the functions and makes the result"
Posting the answer here maybe it helps others too.
Related
I am trying to use couchbase DB and set up authentication for it using Authorization Code flow. I followed the steps in this link. I prepared ConfigJson accordingly. Using Pods i installed Couchbase lite for ios and gave the authenticator in following way:
let url = URL.init(string: "http://my-ip:4984/project_name/_oidc")!
pusher = database.createPushReplication(url)
pusher.continuous = true
let authenticator = CBLAuthenticator.openIDConnect({(loginURL: URL, redirectURL: URL, Nonnull: CBLOIDCLoginContinuation) -> Void in
print(loginURL,redirectURL)
})
pusher.authenticator = authenticator
pusher.start()
But when I Checked it in terminal "http://my-ip:4984/project_name/_oidc/_session" is hit instead and I am not receiving any callback to the mobile. What am i doing wrong? Sorry I am just a beginner. Why is _session added at the end?
You need to set URL of Your database instead of setting _oidc endpoint. Authentification steps are taken care of by Couchbase Lite's Open ID Connect authenticator.
So, You need to use let url = URL.init(string: "http://my-ip:4984/project_name/")!
I am making the following request which is returning Json.
let baseUrl = "http://wex-qa.mybluemix.net/resources/question"
let userName = "yourName#aol.com"
let password = "yourCreds"
let authKey = userName + ":" + password
let client = new HttpClient()
client.DefaultRequestHeaders.Authorization <- new AuthenticationHeaderValue("Basic",authKey)
let input = new Dictionary<string,string>()
input.Add("question","what time is it")
let content = new FormUrlEncodedContent(input)
let result = client.PostAsync(baseUrl,content).Result
let resultContent = result.Content.ReadAsStringAsync().Result
I immediately thought of using the Json Type Provider so I made a local file of the response to be the type def. I then went to load the type where I need the credentials and the content. However, I did not see where the .Load() function have an overload to pass in the credentials and the content. Should I continue to make the request via the HttpClient class and use the .Parse() function?
Thanks in advance.
Expanding on the answer in the comments (which is correct).
I had this problem in 2022 with FSharp.Data 4.2.9. There still seems to be no way to put authorisation credentials into the requests for either defining the JsonProvider type, or the runtime collection of data. With a bit of working around, it can be made to work like a type provider, as described in the question and comment.
Get your credentials for web requests from the site. This often involves a single 'key' rather than a username/password pair.
Instantiate the type provider with sample data from the site (extracted with the required credentials).
At runtime, use HttpClient with Authorization, to read JSON from the URL, and then use the Parse method of the type provide to return typed data. This allows you to use intellisense on the returned data
This example is for the MailChimp API, which supports mailing lists and requires a company API Key on web requests.
First, follow instructions on the site to get 'Credentials' for API calls.
Second, use any method to extract sample JSON to a file. I used the PHP samples provided by MailChimp.
Then define the JsonProvider with that data.
type mcListsTypeProvider = JsonProvider< "./lists_sample_data.json">
Here lists is a fundamental component of the API. In this example, I will be working with the "Sales Subscribers" list.
The next function will read from a URL, and return typed Json data, as if directly from the Load function.
The core of this is the jsonProviderParse argument, which is the Parse method from the JsonProvider.
let loadTypedJson url jsonProviderParse =
use httpClient = new HttpClient()
// Set up authorisation
let mailChimpApiKey = "3ef8dXXXXXXXXXXXXXXXXf61e-us18" // Could be a "userName:passowrd" key
httpClient.DefaultRequestHeaders.Authorization <- AuthenticationHeaderValue("Basic",mailChimpApiKey)
// Get content
let result = httpClient.GetAsync(url : string).Result
let content = result.Content.ReadAsStringAsync().Result
// Parse content, with the Parse method from the JsonProvider
jsonProviderParse content
Then use loadTypedJson as you would myTypeProvider.Load("https:..")
// Find the MailChimp list Id for the "Sales Subscribers" list
let listsUrl = "https://us18.api.mailchimp.com/3.0/lists"
let data = loadTypedJson listsUrl mcListsTypeProvider.Parse
let list_id =
data.Lists
|> Seq.find (fun list -> list.Name = "Sale Subscribers")
|> (fun x -> x.Id)
printfn "Sale Subscribers list_id = %s" list_id
Output: list_id = f21XXXXX85
Intellisense working for the JsonProvider
I tried to use the google apps reseller api with google apps script. To use oauth I need the AuthServiceName. what is the right name? "apps" does not work.
AuthServiceName is defined in your application, its not dependent on the API that you are connecting to, i would suspect that you may not have completed all the steps necessary or that your oauth call is not properly structured.
Here is an example of a call that retrieves the details of domains.
function getCustomer() {
//set up oauth for Google Reseller API
var oAuthConfig1 = UrlFetchApp.addOAuthService("doesNotMatter");
oAuthConfig1.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=https://www.googleapis.com/auth/apps.order.readonly");
oAuthConfig1.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
oAuthConfig1.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken?oauth_callback=https://script.google.com/a/macros");
oAuthConfig1.setConsumerKey(CONSUMER_KEY);
oAuthConfig1.setConsumerSecret(CONSUMER_SECRET);
var options1 = {oAuthServiceName:"doesNotMatter", oAuthUseToken:"always",
method:"GET", headers:{"GData-Version":"3.0"}, contentType:"application/x-www-form-urlencoded"};
//set up user profiles url
var theUrl = "https://www.googleapis.com/apps/reseller/v1/customers/somedomain.com";
//urlFetch for customer list
var customerInfo = "";
try {
var response = UrlFetchApp.fetch(theUrl,options1);
customerInfo = response.getContentText();
} catch(problem) {
Logger.log(problem.message);
}
Logger.log(customerInfo);
}
This will work if
You have a reseller account (I guess i.e. I did not test on my non reseller account)
You have create a project in the API console, and enabled the Reseller API
You know your SECRET and KEY lifted form the console
I have use a read.only scope which is safe, if not you need to set up your tests in the sand box
Let me know if you need any more clarifications
I search for the answer last two days, but can't seem to find the (definitive) answer. I need to get the CSV data from Google Trends, in order to do that I need to login to my Google account. So far I tried to use the following code (originally posted byt #user1883833 in Oauth google trends download CSV file :
static void Main(string[] args)
{
using (var client = new WebClient())
{
var terms = new List<string>() {"debt", "profit", "euro", "dollar", "financial", "economy", "federal reserve", "earnings", "fed", "consumer spending" , "employment", "unemployment", "jobs" };
var username = "your username";
var password = "password";
var response = client.DownloadString(string.Format("https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&Email={0}&Passwd={1}&service=trendspro&source=test-test-v1", username, password));
// The SID is the first line in the response
// The Auth line
var auth = response.Split('\n')[2];
client.Headers.Add("Authorization", "GoogleLogin " + auth);
int i = 1;
while (terms.Count > 0)
{
// google limits 5 sets of terms per request
var arr = terms.Take(5).ToArray();
terms = terms.Skip(5).ToList();
var joined = string.Join("%2C%20", arr);
byte[] csv = client.DownloadData(string.Format("http://www.google.com/trends/trendsReport?hl=en-US&q={0}&cmpt=q&content=1&export=1", joined));
// TODO: do something with the downloaded csv file:
Console.WriteLine(Encoding.UTF8.GetString(csv));
File.WriteAllBytes(string.Format("report{0}.csv", i), csv);
i++;
}
}
}
While the above works fine - it allows only few downloads before "You have reached your quota limit. Please try again later." message, then Google appear to block IP for a looong time (24 hours or more - but only from code, you still CAN download data from the website on the same login, this limitation can by bypassed by proxy - but again, only few queries can be processed before hitting a limit).
As far as I can see - above login, doesn't generate cookies google use in Google trends. I know I can login using DotNetOpenAuth, however the question is: can I login using code only, without rediraction to google login page? I mean something like:
string username="username";
string password="password";
DotNetOpenAuth.GoogleLogin(username,password);
Is it possible? If not - is there any other way to login that would allow normal quota limit?
Thanks in advance.
Best regards.
i found an sdk here:
http://www.baskoro.web.id/facebook-connect-blackberry-HOWTO.html
i tried to run the code both on device and simulator but it shows only white screen and nothing else
i also tried this without result token:
.append("&next=http://www.facebook.com/connect/prompt_permissions.php?api_key=" + "api_key" + "&display=popup&v=1.0&next=http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&fbconnect=true&ext_perm=read_stre...")
but no success
i also tried this without result token:
StringBuffer url = new StringBuffer()
.append("http://m.facebook.com/login.php?")
.append("api_key=")
.append(facebookFacade.getApplicationKey())
.append("&connect_display=page")
.append("&v=1.0")
.append("&fbconnect=true")
.append(
"&next="http://www.facebook.com/connect/login_success.html?xxRESULTTOKENxx&fbconnect=true"
);
i dont have result token
how to get that????
Plzzzzzzzz help
Please use the latest SDK at here instead. You should be able to follow the short tutorial on the same page as well.
Download graph api from http://sourceforge.net/projects/facebook-bb-sdk/.
After that you have to add two thinks.
one is when you want to post a photo to your friends wall ,you have to put one more key-value in the JSONObject(Request) - that is requestObject.put("target_id",getid()) in publisePhoto method facebookuser.java & facebook.java
Second is you have to change
JSONObject responseObject = fb.write(getId() + "/photos", requestObject, pPhoto.getMIMEType(), imageData, true);
to
JSONObject responseObject = fb.write(getId() + "/photos?access_token="+Facebook.token, requestObject, pPhoto.getMIMEType(), imageData, true);in FacebookUser.java & Facebook.java
where token is Static string from Facebook.java and store the value of access_token (you have to add it)
i think before you start with sample codes.
you need to study some of the links.
OAuth 2.0
facebook developer documents
after that you can get
client_id and client_secret from this link