AWQL Error / Can't seem to retrieve any data - c#

I'm in the process of hooking my site into the AdWords API. I seem to be having an issue requesting any kind of data at all from the API.
The errors I receive are all AWQL syntax issues (e.g. Error in query: unexpected input DURING.
Here is my code:
GoogleAdsClient adClient = new GoogleAdsClient();
adClient.Config.OAuth2ClientId = "...";
adClient.Config.OAuth2ClientSecret = "...”;
adClient.Config.OAuth2RefreshToken = "...”;
adClient.Config.DeveloperToken = “...”;
var googleService = adClient.GetService(Google.Ads.GoogleAds.Services.V0.GoogleAdsService);
string query = #"SELECT Impressions,Clicks,Ctr FROM KEYWORDS_PERFORMANCE_REPORT DURING LAST_7_DAYS";
PagedEnumerable<SearchGoogleAdsResponse, GoogleAdsRow> response =
googleService.Search("MY_CUSTOMER_ID", query);
I am fairly certain the AWQL is ok so I'm wondering if it's the setup of the Service I'm using to execute the AWQL that is the issue. Can anyone see anything obvious here?

It looks like you're using the GoogleAds API, not the AdWords API. Could it be that?
If so, here's a migrate reports guide.

Related

Google Spanner - Execute a query using custom credentials

Using C#, I am trying execute a query on Google Spanner db. I understand I can use the SpannerClient and all the current documentation explains how to execute a query quite simply, however these examples all assume default environment credentials.
I would like to execute a query against a given database but using custom credentials. So something like
var credentials = GoogleCredential.FromJson(jsonData);
SpannerClient client = new SpannerClient(connectionString, credentials)
var cmd = client.CreateSelectCommand("SELECT SingerId, AlbumId, AlbumTitle FROM Albums");
etc
I am currently unable to figure out how to do this?
Thanks
Currently this isn't as clean as we'd like it to be. You need to create a ChannelCredentials for the credentials, and provide that to the SpannerConnectionStringBuilder:
// First load the credentials, scope them, and convert to ChannelCredentials.
// You may want to move this to a separate method.
var googleCredential = GoogleCredential.FromJson(jsonData);
googleCredential = googleCredential.CreateScoped(SpannerClient.DefaultScopes);
// Use self-signed JWTs for service accounts.
// (This isn't strictly required, but reduces network usage.)
if (googleCredential.UnderlyingCredential is ServiceAccountCredential serviceCredential)
{
googleCredential = GoogleCredential.FromServiceAccountCredential(
serviceCredential.WithUseJwtAccessWithScopes(true));
}
// Note: this requires a using directive of "using Grpc.Auth;"
var channelCredentials = googleCredential.ToChannelCredentials();
// Now create a SpannerConnection with the SpannerCredentials
using var conn = new SpannerConnection(connectionString, credentials);
using var cmd = conn.CreateSelectCommand("SELECT ...");
...
We definitely hope to improve this - we have a tracking bug you might want to subscribe to so that you can simplify your code when it's fixed.

Trying to use ONVIF webservice with C#, methods without parameters work, others do not with either "bad request" or "closed unexpectedly"

The call to GetSystemDateAndTime works.
The call to GetDeviceInformation gives a bad request.
The WSDL is : https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl
I've tried numerous things and the error message doesn't help... Another application seems to successfully access the camera, but I couldn't figure out how they do it from their source code at : https://sourceforge.net/projects/onvifdm/
But since they can do it I believe there has to be a way... Or at least a way to identify why my code fails and their works, any help is very appreciated.
The code is :
Binding binding;
HttpTransportBindingElement httpTransportBindingElement = new HttpTransportBindingElement();
httpTransportBindingElement.AuthenticationScheme = AuthenticationSchemes.Digest;
binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, Encoding.UTF8), httpTransportBindingElement);
DeviceClient deviceClient = new DeviceClient(binding, new EndpointAddress("http://192.168.0.15/onvif/device_service"));
deviceClient.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
deviceClient.ClientCredentials.HttpDigest.ClientCredential.UserName = "username";
deviceClient.ClientCredentials.HttpDigest.ClientCredential.Password = "password";
var x = deviceClient.GetSystemDateAndTime();
var x2 = deviceClient.GetDeviceInformation(out string model, out string firmwareversion, out string serialnumber, out string hardwareId);
I have seen this occur if the time between the client and the server are outwith a certain range, usually just a few seconds. Ensure both are using the same NTP server and it might fix the problem.
Some clients get around this by usin the timestamp from the GetSystemDataAndTime call within the requests of other messages to get around this check.
On some cameras it is also possible to turn off the strict checks

androidpublisher api google authorname empty

I have been testing the google api to get the comments of my android application in google play and it always returns me the empty authorname, do I need some other permission? I put the json of what returns me.
Thank you!
I suspect this is an issue with fields
var request = service.Reviews.List ("my.app");
request.Fields = "*";
var results = request.ExecuteAsync() ;
I don't have access to that api so the code is an educated guess give it a try let me know if it doesn't work. Try testing it here as well Google APIs explorer.
Update 1:
I have one last guess try running a Reviews.Get request after your review.list maybe the name isn't return in the list it should be though.
var request = service.Reviews.Get("my.app",reviewIdFromListRequest);
request.Fields = "*";
var results = request.ExecuteAsync() ;
If this doesn't work i say we log it as a bug.
Update 2:
apparently its a documented bug
Found in this documentation page reviews

Facebook Retrive Data using Graph API using c#

i have created desktop Facebook application using c# .net. i want to retrieve users message,post and chat history. which is convenient way to retrieve users all information.i have started with Facebook Graph API but i am not getting any example.
can any one help me ?
A bit late to the party but anyway:
Add a reference to System.Net.Http and Newtonsoft.Json
string userToken = "theusertokentogiveyoumagicalpowers";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("https://graph.facebook.com");
HttpResponseMessage response = client.GetAsync($"me?fields=name,email&access_token={userToken}").Result;
response.EnsureSuccessStatusCode();
string result = response.Content.ReadAsStringAsync().Result;
var jsonRes = JsonConvert.DeserializeObject<dynamic>(result);
var email = jsonRes["email"].ToString();
}
Go to developer.facebook.com -> Tools & Support -> Select Graph API Explorer
Here U get FQL Query, Access Token
Then write code in C#.....
var client = new FacebookClient();
client.AccessToken = Your Access Token;
//show user's profile picture
dynamic me = client.Get("me?fields=picture");
pictureBoxProfile.Load(me.picture.data.url);
//show user's birthday
me = client.Get("me/?fields=birthday");
labelBirthday.Text = Convert.ToString(me.birthday);
http://www.codeproject.com/Articles/380635/Csharp-Application-Integration-with-Facebook-Twitt
I hope this will help you.!!!
you can check the Graph explorer tool on Developer.facebook.com , go to Tools and select graph explorer, its a nice tool which gives you exact idea about what you can fetch by sending "GET" and "POST" method on FB Graph APis
From what i see the app now only uses webhooks to post data to a data endpoint (in your app) at which point you can parse and use this. (FQL is deprecated). This is used for things like messaging.
A get request can be send to the API to get info - like the amt. of likes on your page.
The docs of FB explain the string you have to send pretty nicely. Sending requests can be done with the webclient, or your own webrequests.
https://msdn.microsoft.com/en-us/library/bay1b5dh(v=vs.110).aspx
Then once you have a string of the JSON formatted page you can parse this using JSON.NET library. It's available as a NUGEt package.

Facebook Graph API put Like issue.?

I am using Facebook Graph API and I wanted to put Like of any comment so I am doing like this.
FacebookGraphAPI obj = new FacebookGraphAPI(AccessToken);
obj.PutLike(item["id"].ToString().Replace("\"", ""));
It is not working even it will not give me error so how I can put the like.
Using the latest API, here's how to do a like (this assumes that there is a graph api like connection on the object being liked)
FacebookClient client = new FacebookClient(userAccessToken);
var result = client.Post(item["id"] + "/likes", null);
ProcessResult(result); // your code to determine how to handle the result being sent back from Facebook
The above code is from a current production working app of mine.
Happy coding!

Categories

Resources