Evernote findNotes by sourceURL - evernote

I'm trying to search notes by the attribute sourceURL but it seems API is stripping away the protocol and the result is no results. Here is the code
var notesTransport = new Thrift.Transport(
Eventnote.Auth.oauth.getParameter(Eventnote.Auth.note_store_url_param));
var notesProtocol = new Thrift.Protocol(notesTransport);
var noteStore = new NoteStoreClient(notesProtocol, notesProtocol);
if (!noteStore) {
Eventnote.Logger.error("[EVERDU] Connection failure during getting note store");
return;
}
var filter = new NoteFilter();
filter.words = "sourceURL:" + url + "*";
try {
var results = noteStore.findNotes(Eventnote.Auth.get_auth_token(), filter,
0, 100);
...
The reasults objects looks like this
{
"startIndex":0,
"totalNotes":0,
"notes":[
],
"stoppedWords":null,
"searchedWords":[
"//github.com/sameersbn/docker-gitlab*"
],
"updateCount":18461
}
Is there something I am missing?

Not sure if that counts as a bug on Evernote's end or not, butyou can add double quotes around your url to make it work.
filter.words = "sourceURL:\"" + url + "*\"";

Related

Restrict typeform to single submission on Wordpress post

Have a simple typeform embedded into a post in Wordpress. Nothing fancy at all. Embed code pulled direct from Typeform.
However, people can submit multiple times. ie. One person could theoretically do it 100 times.
Typeform have advised a cookie will solve this, and restrict a user to a single submission - but really do not know where to begin there. Is there a simple, quick fix that could do such a thing? Any ideas completely welcome!
One of the solutions could be only showing the embedded typeform if the cookie does not exist.
not really sure how you would do this in Wordpress.
But the logic is:
const embedElement = document.querySelector('.target-dom-node')
const displayed = getCookie("displayed_typeform");
if (displayed){
embedElement.innerHTML="<h2>Typeform already displayed once.</h2>"
} else if(!displayed && displayed === "") {
setCookie("displayed_typeform", true, 365);
showEmbed();
}
setCookie and getCookie are two functions that deal with cookie management
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
You can find a complete project that demonstrates this feature here.

Cancel a complete PNR

I'm writing a service which automtically cancels a PNR left on a certain queue. This sounds pretty straight forward with the OTA_CancelLLSRQ request, however it appears I have to loop through each segment individually, or is there a way I can cancell ALL segments at once?
In the application we defined a PNR class, this class contains all of the information we can obtain with the "" call.
To cancel the PNR I currently use the following code:
MessageHeader msgHeader = new MessageHeader
{
ConversationId = "TestSession",
CPAId = licenseId,
Action = "OTA_CancelLLSRQ",
Service = new Service { Value = "OTA_CancelLLSRQ" },
MessageData = new MessageData
{
MessageId = "xxx",
Timestamp = DateTime.UtcNow.ToString("s") + "Z"
},
From = new From()
{
PartyId = new PartyId[]
{
new PartyId { Value = "WebServiceClient"}
}
},
To = new To()
{
PartyId = new[]
{
new PartyId { Value = "WebServiceSupplier"}
}
}
};
var segmentList = new List<OTA_CancelRQSegment>();
foreach (var segment in pnrObject.Segments)
{
var requestSegment = new OTA_CancelRQSegment
{
Number = segment.SegmentNumber.ToString()
};
segmentList.Add(requestSegment);
}
var request = new OTA_CancelRQ()
{
Version = "2.0.0",
TimeStamp = DateTime.UtcNow,
TimeStampSpecified = true,
Segment = segmentList.ToArray()
};
OTA_CancelRS response = null;
Policy.Handle<SoapException>()
.Or<WebException>()
.WaitAndRetry(new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(1)
})
.Execute(() =>
{
using (OTA_CancelService serviceObj = new OTA_CancelService())
{
serviceObj.MessageHeaderValue = msgHeader;
serviceObj.Security = new Security1 { BinarySecurityToken = token };
response = serviceObj.OTA_CancelRQ(request);
}
});
It compiles & builds, but I haven't gotten around testing it just yet. :-)
In the documentation I found the following request:
<OTA_CancelRQ Version="2.0.0">
<Segment Type="entire"/>
</OTA_CancelRQ>
How do I encode this using the object model the webservice expects?
Steps for cancelling PNR is as follows.
STEP1: SessionCreateRQ
STEP2: TravelItineraryReadRQ
STEP3: OTA_CancelRQ
STEP4: EndTransactionRQ
STEP5: SessionCloseRQ
In case of SOAP SERVICES your request XML for STEP3 (i.e OTA_CancelRQ)will be as follows.
<OTA_CancelRQ EchoToken="String" TimeStamp="2001-12-17T09:30:47-05:00" Target="Production" Version="2003A.TsabreXML1.0.1" SequenceNmbr="1" PrimaryLangID="en-us" AltLangID="en-us" xmlns="http://webservices.sabre.com/sabreXML/2003/07" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<POS>
<Source PseudoCityCode="PCC"/>
</POS>
<TPA_Extensions>
<SegmentCancel Type="Entire">
</SegmentCancel>
</TPA_Extensions>
</OTA_CancelRQ>
I hope this will make your knowledge more clear.
You can specify "entire" type like the below to cancel the entire Itinerary of a PNR.
<OTA_CancelRQ Version="2.0.0">
<Segment Type="entire"/>
</OTA_CancelRQ>
here is the request part of my code in c#, hope this help add a refrence to proxy class for OTA_CancelRQ.
OTA_CancelRQ rq = new OTA_CancelRQ();
List<OTA_CancelRQSegment> segmentCancelList = new List<OTA_CancelRQSegment>();
OTA_CancelRQSegment segmentCancel = new OTA_CancelRQSegment();
OTA_CancelRQSegmentType segmentType = new OTA_CancelRQSegmentType();
segmentType = OTA_CancelRQSegmentType.entire;
segmentCancel.Type = segmentType;
segmentCancel.TypeSpecified = true;
segmentCancelList.Add(segmentCancel);
rq.Segment = segmentCancelList.ToArray();
Thanks.
cancelRQ.tPA_ExtensionsField = new CancelRequest.TPA_Extensions
{
segmentCancelField = new CancelRequest.TPA_Extensions.SegmentCancel
{
typeField = "Entire"
}
};
call OTA_CancelLLSRQ Perform a transaction after the original booking was completed (cancel the itinerary that was booked, in this case).

Using Page Hits for Segmentation in Adobe CQ5

I am trying to set up personalised content in CQ5 using segmentation. When I use the out of the box "Page Hits" option it doesn't work. Is there some extra configuration I have to do to use Page Hits?
I've set up two segments applied to two teaser pages. For the first one I've used
number of page hits is less than 4.
For the second I've used number of page hist is greater than 3.
Note, the teasers show up when I use Referral Keywords to test so I think the rest of the configuration is correct.
Can anyone give some advice about how to get the Page Hits segmentations to work?
Just in case anyone else has this same problem, I solved it by using a session store and set a cookie on the users browser to record how many times they had been to a particular page. Using that, I was able to configure my segments and personalise areas of the page based on number of visits the user had made to that page.
Code for the session store:
//Create the session store
if (!CQ_Analytics.MyStore) {
CQ_Analytics.MyStore = new CQ_Analytics.PersistedSessionStore();
CQ_Analytics.MyStore.STOREKEY = "MYSTORE";
CQ_Analytics.MyStore.STORENAME = "myclientstore";
CQ_Analytics.MyStore.data={};
CQ_Analytics.MyStore.findPageName = function(){
var locationName = location.pathname;
var n = location.pathname.indexOf("html");
if(n !== -1){
locationName = locationName.split('.')[0];
}
return locationName.split("/").slice(-1);
}
CQ_Analytics.MyStore.title = CQ_Analytics.MyStore.findPageName() + "-pageviews";
CQ_Analytics.MyStore.loadData = function(pageViewed) {
CQ_Analytics.MyStore.data = {"pageviewed":pageViewed};
}
CQ_Analytics.MyStore.getCookie = function(cname) {
console.log("getting the cookie");
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0){
console.log("return value for cookie is " + c.substring(name.length,c.length) );
return c.substring(name.length,c.length);
}
}
return "";
}
CQ_Analytics.MyStore.setCookie = function(cname, cvalue, exdays) {
console.log("setting the cookie");
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
CQ_Analytics.MyStore.checkCookie = function() {
console.log("checking for cookie");
var pViewd = CQ_Analytics.MyStore.getCookie(CQ_Analytics.MyStore.title);
if (pViewd != "") {
console.log("cookie is found and Viewed is " + pViewd);
pViewd = parseInt(pViewd) + 1;
CQ_Analytics.MyStore.setCookie(CQ_Analytics.MyStore.title, pViewd, 365);
CQ_Analytics.MyStore.loadData(pViewd.toString());
} else {
if (pViewd === "" || pViewd === null) {
console.log("cookie not found");
CQ_Analytics.MyStore.setCookie(CQ_Analytics.MyStore.title, "1", 365);
CQ_Analytics.MyStore.loadData("1");
}
}
}
CQ_Analytics.MyStore.checkCookie();
}
//register the session store
if (CQ_Analytics.CCM){
CQ_Analytics.CCM.register(CQ_Analytics.MyStore)
}
The most useful documentation I found was this: https://docs.adobe.com/docs/en/cq/5-6-1/developing/client_context_detail.html#par_title_34

google places api many filters by type Ex.: restaurant,cafe

I'm trying to change the radius category/type filter for a checkbox, so I changed the var type to an array.
ORIGINAL WORKING:
var type;
for (var i = 0; i < document.controls.type.length; i++){
if (document.controls.type[i].checked){
type = document.controls.type[i].value;
}
}
startBox.setBounds(map.getBounds());
var search = {
// keyword: 'comocomo', // not needed with the autocomplete / startBox
bounds: map.getBounds()
};
if (type != 'establishment'){
search.types = [ type ];
}
places.search(search, function(placesArr, status){
THE ONE WITH THE ARRAY NOT WORKING: edited:
var type=[];
for (var i = 0; i < document.controls.type.length; i++){
if (document.controls.type[i].checked){
type.push(document.controls.type[i].value)
}
}
startBox.setBounds(map.getBounds());
var search = {
bounds: map.getBounds()
};
var quotedAndCommaSeparated = "'" + type.join("','") + "'";
alert(quotedAndCommaSeparated); // 'establishment','restaurant','lodging'
search.types = [ quotedAndCommaSeparated ];
I made many tests, and I don't see what I'm doing wrong. the map doesn't even show.
What's this meant to be, doesn't look like valid Javascript to me:
var type[];
Should be
var type = [];
Fix the javascript errors in your code otherwise the map won't show up.
Update:
What you have in quotedAndCommaSeparated is a string like "'a','b','c'" that looks a bit like the contents of an array: ['a','b','c']. But it's not an array, it's just a single string. If you check the length of your search.type array, I'm guessing it equals 1.
What you can do is split your string on the comma to turn it into an array:
search.types = quotedAndCommaSeparated.split(",");

Is there a simple way in ASP.Net to get the current URL with some query parameters changed?

I've had several cases where I had a page with several query parameters - most recently a search results page - and needed to create a link to the same page with one or more query parameters changed in the URL. This seems like such a common use case that I feel as though there must be some simple built-in way of doing it.
Right now, I'm using a function I wrote which takes in a dictionary of parameters and values and merges them with the params and values from Request.QueryString. Parameters given with a null value are removed. It works, but I'm open to simpler methods.
Minor improvements I'd suggest:
//...
{
UriBuilder ub = new UriBuilder(Request.Url);
//...
ub.Query = string.Join("&", parameters.Select(kv => string.Format("{0}={1}", Server.UrlEncode(kv.Key), Server.UrlEncode(kv.Value))));
return ub.ToString();
}
Edit
Actually the return value should also be a Uri type but I didn't want to introduce any breaking changes.
The function I'm using now:
public string ThisPageWithParams(IDictionary<string, string> newParameters)
{
string url = Request.Url.AbsolutePath + "?";
var parameters = new Dictionary<string, string>();
foreach (string k in Request.QueryString)
{
parameters[k] = Request.QueryString[k];
}
foreach (var kv in newParameters)
{
if (newParameters[kv.Key] == null)
{
parameters.Remove(kv.Key);
}
else
{
parameters[kv.Key] = kv.Value;
}
}
url += string.Join("&", parameters.Select(kv => Server.UrlEncode(kv.Key) + "=" + Server.UrlEncode(kv.Value)));
return url;
}

Resources