Javascript and Wordpress - wordpress

Two related questions:
Is there any good documentation on the Fusion Tables Javascript API? I've found a list of methods, but with little info on return values, semantics, or usage idioms.
Is there any guidance (or suggested plugins or idioms) for integrating the FT Javascript API into a locally hosted Wordpress site?

There is some documentation here:
https://developers.google.com/fusiontables/docs/v1/getting_started#JS
but I didn't find it very useful.
But this example, in the context of the Google Maps API I found very useful for the new API 1.0
https://googledrive.com/host/0B5KVZ6J1ohN_Q3ZqVkFGSGZ2cEE/custom%20markers%20code/customicons_viaApi.html
You'll need to view and save the source. Also if you search the FT tag for JSONP you will find many examples using the old pre 1.0 API but the concepts are the same, just the AJAX end point has changed and the need for an apiKey.
The basic idea is that any FT query will return a JSON object with both columns and rows members, very much like a CSV response.
As the example above shows:
function onDataFetched(data) {
var rows = data.rows;
var cols = data.cols;
...
}

Related

GMB - Removal of LocationState object in Business Information API

Google deprecated the old GMB API v4.9 account.locations.get endpoint, and replaced it with Business Information API v1 locations.get.
Code change that affects me is:
Removal of LocationState object. The existing fields have been moved into Metadata.
The new Metadata object does not return the attributes LocationState object contained before. The ones I'm interested in are:
isVerified
isPublished
isSuspended
isDisabled
isDisconnected
etc...
My question is:
How could I get this data without using deprecated endpoints?
Try Verification API getVoiceOfMerchantState
isVerified (verify),
isPublished (hasVoiceOfMerchant=true AND hasBusinessAuthority=true),
isSuspended (complyWithGuidelines),
isDuplicate (resolveOwnershipConflict).
isDisabled & isDisconnected have no equivalent in new API
As far as I can see, based on the link you have sent it is written:
Endpoint URL:
Endpoints for all business information, attributes, categories, chains and locations search are accessible at https://mybusinessbusinessinformation.googleapis.com/v1/ instead of https://mybusiness.googleapis.com/v4/
The path name for locations endpoints has changed from
accounts/accountId/locations/locationId to locations/locationId
Maybe it was better if you could provide the request uri in the previous version so we could help you more precisely. Anyhow, what I tested in the google playground is as follows:
open [https://developers.google.com/oauthplayground]
after setting your clientId and Authorisation stuff, in the Request URI write
https://mybusinessbusinessinformation.googleapis.com/v1/locations/XXXXX?readMask=storeCode,metadata,profile,serviceArea,labels,adWordsLocationExtensions
instead of XXXXX, write your locationId
you can write different readMask fields, The possible fields for readMask are:
play with different fields to check if you have your desired one or not readMask="storeCode,regularHours,name,languageCode,title,phoneNumbers,categories,storefrontAddress,websiteUri,regularHours,specialHours,serviceArea,labels,adWordsLocationExtensions,latlng,openInfo,metadata,profile,relationshipData,moreHours";
If above does not help you, in the link below I see that all metadata attribute of a location might be:
Click [here] (https://developers.google.com/my-business/reference/businessinformation/rest/v1/accounts.locations#Location.Metadata)

Get Source and Medium from ga.js

I have a newsletter page on my website which I'd like to also use to capture some additional information about the user using Google Analytics.
Using the getAll() method from ga.js I can get the referrer URL (if any), however I cannot see the medium or source data. Is this possible to retrieve using their ga.js library?
Retrieve specific tracker from the list of trackers you obtained.
Use the following to access the fields source and medium.
tracker.get('campaignSource') and tracker.get('campaignMedium')
Additional help from below links.
Access data from ga object:
https://developers.google.com/analytics/devguides/collection/analyticsjs/accessing-trackers
Field reference:
https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference
This is not possible with ga.js.
However, you can use custom JavaScript to deduce the same information.
If you only want this capability, then I suggest you have a look at the library I wrote: https://github.com/ilkkapeltola/visitdata
Once the library is included, you can run visitData.get(), which returns an object with exactly the data you need.
If you are using google analytics core reporting api try this
'metrics': 'ga:sessions ,ga:pageviews',
'dimensions' : 'ga:source,ga:medium'

Meteor: Single-Document Subscription

Whenever I encounter code snippets on the web, I see something like
Meteor.subscribe('posts', 'bob-smith');
The client can then display all posts of "bob-smith".
The subscription returns several documents.
What I need, in contrast, is a single-document subscription in order to show an article's body field. I would like to filter by (article) id:
Meteor.subscribe('articles', articleId);
But I got suspicious when I searched the web for similar examples: I cannot find even one single-document subscription example.
What is the reason for that? Why does nobody use single-document subscriptions?
Oh but people do!
This is not against any best practice that I know of.
For example, here is a code sample from the github repository of Telescope where you can see a publication for retrieving a single user based on his or her id.
Here is another one for retrieving a single post, and here is the subscription for it.
It is actually sane to subscribe only to the data that you need at a given moment in your app. If you are writing a single post page, you should make a single post publication/subscription for it, such as:
Meteor.publish('singleArticle', function (articleId) {
return Articles.find({_id: articleId});
});
// Then, from an iron-router route for example:
Meteor.subscribe('singleArticle', this.params.articleId);
A common pattern that uses a single document subscription is a parameterized route, ex: /posts/:_id - you'll see these in many iron:router answers here.

sort Ektron content types

Ektron 801 SP1
I am using the following code to fetch some smart form content. Can I pre-sort (using OrderByField?) before I fetch 20 rows? I am sorting memberlist but that is after the fact and kinda useless. What am I missing?
Criteria<ContentProperty> criteria1 = new Criteria<ContentProperty>();
criteria1.AddFilter(ContentProperty.XmlConfigurationId, CriteriaFilterOperator.EqualTo, MEMBERS_ID);
criteria1.PagingInfo = new PagingInfo(20);
List<ContentType<member>> memberslist = contentTypeManager.GetList(criteria1);
I have good news and bad news for you.
First, the good news. You can sort by Content Properties with the Criteria object before you pull the 20 items. You'll want to use the OrderByField and OrderByDirection properties of the criteria.
criteria.OrderByField = ContentProperty.DateCreated;
criteria.OrderByDirection = EkEnumeration.OrderByDirection.Descending;
The bad news comes when trying to order items based on fields within the Smart Form. You might be able to do so using the IndexSearch API, but since Ektron 8.0* still relies on Microsoft's Indexing Service, I'm not a fan of that approach and don't have any code to share. If you choose to go that route, the premise is to use search to return the content IDs in the correct order, then use the criteria, as you are, to get items with those IDs.
What you can do with just the API is use Microsoft LINQ to sort the data after it's loaded, but in order to get the right results in the right order you have to load all items first (and ideally cache them to minimize performance impact). I'm using one of my content types as an example, but you should get the idea.
var membersList = new List<SlideBannerType>();
var sortedList = membersList.OrderBy(s => s.EnableAlternateText);
var firstpage = sortedList.Take(20);
var nextpage = sortedList.Skip(20).Take(20);
It's not ideal, but it does work very well for smaller (in the hundreds, perhaps thousands, but not tens of) data sets.
The second bit of good news, though, is that Ektron uses Microsoft Search Server for versions 8.5 and up. This has a much, much more robust API and performs fantastic (both in terms of speed and reliability). The premise would actually stay the same as that for the IndexSearch, use Search to get the IDs in the right order, and then ContentManager (or ContentTypeManager) to get the items. I've used this approach several times, albeit not with Smart Forms specifically. Your best result would come from upgrading to 8.6 and Microsoft Search Server and using the two APIs together to get each page of data. In doing so, it would actually be almost trivial at that point to mix in advanced search and filter options as well with the new search APIs.

Twitter Library for ASP.NET MVC that implements REST API

I been looking for a twitter lib for my ASP.NET NET MVC 3 software, but I need to implement the REST API functions that I nor found in Twitter Helper or Twitterizer. Rest API allow me to use a Find People query.
There is another one could solve my problem?
My suggestion would be to try looking into a library, such as TweetSharp that already has wrappers around a substantial amount of the Twitter API methods. If that doesn't work for you, consider writing your own wrapper around the methods you need using libraries such as HammockRest or RestSharp that have support for working with http, oauth and other such features that may assist you.
Looking better in Twitterizer I found what I need, perform Search People, and other functions. I recommend Twitterizer to use twitter in ASP.NET MVC 3, ´cause the oAuth process has a better code.
Here the Sample code to peform Search People in twitter using Twitterizer :
UserSearchOptions options = new UserSearchOptions();
options.NumberPerPage = 40;
options.Page = 1;
TwitterResponse<TwitterUserCollection> usersResponse = TwitterUser.Search(tokens,pesquisa.Conteudo,options);
if (usersResponse.Result == RequestResult.Success)
{
StringBuilder list = new StringBuilder();
foreach (var u in usersResponse.ResponseObject)
{
list2.Append(u.Name + "-" + u.Id);
}
ViewBag.Result_Twitter = list.ToString();
}

Resources