iTunes podcast get feed url - rss

I am trying to get feed url from iTunes podcast, for example https://podcasts.apple.com/us/channel/lemonada/id6442462434
var url = 'https://itunes.apple.com/lookup'
var params = 'id='+id+'&entity=podcast';
xhrRequest = new XMLHttpRequest();
xhrRequest.onreadystatechange = function() {
if (xhrRequest.readyState == 4) {
console.log(xhrRequest.responseText)
}
}
xhrRequest.onerror = function(e) {
};
xhrRequest.open('POST', url);
xhrRequest.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
xhrRequest.send(params);
But I get empty results, like:
{resultCount: 0, results: Array(0)}
I want to get feed url so I can parse podcast rss.

Related

New gtag google analytics add url _gl manually

I'm trying to add to URL the value of _gl in order to apply cross-domain.
Currently, I tried these options:
const decorateUrl = (urlString: string) => {
var ga = window.dataLayer;
var tracker;
if (ga && typeof ga.getAll === 'function') {
tracker = ga.getAll()[0]; // Uses the first tracker created on the page
urlString = (new window.gaplugins.Linker(tracker)).decorate(urlString);
}
return urlString;
}
and
const decorateURL = (url: string) => {
let destinationLink = false;
var ga = window[window['GoogleAnalyticsObject']];
console.log(ga,'ga test decorate')
if (ga) {
let tracker = ga.getAll()[0];
let linker = new window.gaplugins.Linker(tracker);
destinationLink = linker.decorate(url);
}
return (destinationLink ? url + '?' + destinationLink : url);
}
but none of these set _gl code to URL.
and I inject in the header this code
let gtagLinkScript = destinationWindow.document.createElement("script");
gtagLinkScript.setAttribute('async', 'true');
gtagLinkScript.setAttribute('src', `https://www.googletagmanager.com/gtag/js?id=${ trackingID }`);
and
let gtagAnotherScript = destinationWindow.document.createElement("script");
gtagAnotherScript.innerText = `gtag('set', 'linker', {'domains': [\'${crossDomain}\']});gtag(\'config\', \'${ trackingID }\');`;
can someone help?
In a GA4 property the recommendation is to pass client_id and session_id over the url: https://support.google.com/analytics/answer/10071811?hl=en#zippy=%2Cmanual-setup

Need help to implement PhoneGap/Cordova ContentSync Plugin

Have a question regarding contentsync phonegap plugin (https://www.npmjs.com/package/phonegap-plugin-contentsync).
Will be very appreciated if someone could help.
The core of the problem is that my REST server allowing me to download .epub files (witch are same as .zip) only by sending GET request similar to:
https://test-api.books.com/api/getPublishedEpub?session_hash=1235&publication_id=abv1243'
Providing this link to the plugin '.sync' call I get a 'Invalid request method' response from the server...
While trying to download ordinary .zip everything works just fine.
var pub_id = $scope.currentBook.publication_id, epubUrl = 'https://test-api.books.com/api/getEpub?session_hash='
+ $rootScope.sessionHash+ '&publication_id=' + pub_id;
var downloadBtn = document.getElementById("downloadBtn");
console.log('Download cliked');
var sync = ContentSync.sync({ src: epubUrl, id: 'book'+ pub_id});
sync.on('progress', function (data) {
downloadBtn.innerHTML = "Downloading: " + data.progress + "%";
});
sync.on('complete', function (data) {
console.log(data.localPath);
for (var x = 1; x <= 17; x++) {
var fileUrl = "file://" + data.localPath;
console.log(fileUrl);
}
downloadBtn.innerHTML = 'Download';
});

MeteorJS: CALLBACKS

PROBLEM: I want to parse the elements in a page from another website, glue resulting elements in an object and insert it in a Mongo collection. Before insertion i want to check if my Mongo yet has an identical object. If it does it shall exit the running functions, otherwise i want the script to start parsing the next target.
Example:
I have a function that connects to a webpage and returns its body content
It is parsed
When <a></a> elements are met, another callback is called in which all parsed elements are merged in one object and inserted in a collection
My code :
var Cheerio = Meteor.npmRequire('cheerio');
var lastUrl;
var exit = false;
Meteor.methods({
parsing:function(){
this.unblock();
request("https://example.com/", Meteor.bindEnvironment(function(error, response, body) {
if (!error && response.statusCode == 200) {
$ = Cheerio.load(body);
var k = 1;
$("div.content").each(function() {
var name = $...//parsing
var age = $....//parsing
var url = $...//parsing <a></a> elements
var r = request("https://example.com/"+url, Meteor.bindEnvironment(function(error, response, body) {
lastUrl = response.request.uri.href;// get the last routing link
var metadata = {
name: name,
age: age
url: lastUrl
};
var postExist;
postExist = Posts.findOne(metadata); // return undefined if doesnt exist, AND every time postExist = undefined ??
if (!postExist){
Posts.insert(metadata);// if post doesnt exist (every time go here ??)
}
else {
exit = true; // if exist
}
}));
if (exit === true) return false;
});
}
}));
}
});
Problem 1 : The problem is my function works every time, but it doesn't stop even if the object exists in my collection
Problem 2 : postExist is always undefined
EDIT : The execution must stop and wait until the second request's response.
var url = $...//parsing <a></a> elements
//STOP HERE AND WAIT !!
var r = request("https://example.com/"+url, Meteor.bindEnvironment(function(error, response, body) {
Looks like you want the second request to be synchronous and not asynchronous.
To achieve this, use a future
var Cheerio = Meteor.npmRequire('cheerio');
var Future = Meteor.npmRequire('fibers/future');
var lastUrl;
var exit = false;
Meteor.methods({
parsing:function(){
this.unblock();
request("https://example.com/", Meteor.bindEnvironment(function(error, response, body) {
if (!error && response.statusCode == 200) {
$ = Cheerio.load(body);
var k = 1;
$("div.content").each(function() {
var name = $...//parsing
var age = $....//parsing
var url = $...//parsing <a></a> elements
var fut = new Future();
var r = request("https://example.com/"+url, Meteor.bindEnvironment(function(error, response, body) {
lastUrl = response.request.uri.href;// get the last routing link
var metadata = {
name: name,
age: age
url: lastUrl
};
var postExist;
postExist = Posts.findOne(metadata); // return undefined if doesnt exist
if (!postExist) {
Posts.insert(metadata);// if post doesnt exist (every time go here ??)
fut.return(true);
} else {
fut.return(false);
}
}));
var status = fut.wait();
return status;
});
}
}));
}
});
You can use futures whenever you can't utilize callback functions (e.g. you want the user to wait on the result of a callback before presenting info).
Hopefully that helps,
Elliott
This is the opposite :
postExist = Posts.findOne(metadata); // return undefined if doesnt exist > you're right
if (!postExist){ //=if NOT undefined = if it EXISTS !
Posts.insert(metadata);
}else {
exit = true; // if undefined > if it DOES NOT EXIST !
}
You need to inverse the condition or the code inside

Publish forum replies with embedded user data

I am trying to publish forum replies to a specific thread, but I would like those reply documents to include extra information about the user that posted it.
I don't want to "save" that extra information on the reply itself but rather, publish an "improved" version of it.
I am doing something similar on client-side already with mycollection.find().map() and using the map function to embedded extra information on each of the returned documents, however, Meteor publish cannot seem to publish an array, only a Cursor, so the simple map function is off limits.
Is there a way to achieve this? Maybe a "map" function that returns a Cursor?
I am not using Meteor.methods so that I can have reactivity, because with them I could just return an array and use it as normal.
Here is an example of my code (that fails, but sends gives an idea of what I need):
Meteor.publish("forumthread", function(thread){
return forumReplies.find({thread: thread}).map(function(r){
// lets fill in additional data about each replies owner
var owner = Meteor.users.findOne({_id: r.owner});
if(!owner)
return; // no owner no reply..
if(!owner.forumStats){
owner.forumStats = {};
owner.forumStats.postCount = 0;
owner.forumStats.postLikes = 0;
owner.forumStats.title = "The Newbie";
owner.forumStats.tag = "Newbie";
Meteor.users.update({_id: owner._id}, {$set:{ forumStats:owner.forumStats }});
}
r.ownerid = owner._id;
r.ownerUsername = owner.username;
r.ownerPostCount = owner.forumStats.postCount;
r.ownerPostLikes = owner.forumStats.postLikes;
r.ownerTitle = owner.forumStats.title;
r.ownerTag = owner.forumStats.tag;
return r;
});
});
Thank you.
Ended up doing this (found out that Christian Fritz also suggested it):
Meteor.publish("serverforumthread", function(thread){
check(thread, String);
var replies = forumReplies.find({thread: thread});
var users = {};
replies.map(function(r){
users[r.owner] = r.owner;
});
var userids = _.map(users, function(value, key){ return value; });
var projectedFields = {_id:1, username:1, forumStats: 1, services: 0};
var usrs = Meteor.users.find({_id:{$in: userids}}, projectedFields);
var anyUpdateToUsers = false;
usrs.map(function(owner){
var changed = false;
if(!owner.username){
owner.username = owner.emails[0].address.split("#")[0];
changed = true;
}
//owner.forumStats = undefined;
if(!owner.forumStats){
owner.forumStats = {};
owner.forumStats.postCount = 0;
owner.forumStats.postLikes = 0;
owner.forumStats.title = "the newbie";
owner.forumStats.tag = "newbie";
owner.forumStats.img = "http://placehold.it/122x122";
changed = true;
}
if(changed){
anyUpdateToUsers = true;
Meteor.users.update({_id: owner._id}, {$set:{ forumStats:owner.forumStats }});
}
});
if(anyUpdateToUsers) // refresh it
usrs = Meteor.users.find({_id:{$in: userids}}, projectedFields);
usrs.map(function(owner){
console.log(owner);
});
return [replies, usrs];
});
It works great with the following client side:
Template.forumReplyOwner.helpers({
replyOwner: function(reply){
var owner = Meteor.users.findOne({_id: reply.owner});
console.log(reply, owner);
if(!owner || !owner.forumStats) return; // oh shait!
var r = {};
r.owner = owner._id;
r.ownerUsername = owner.username;
r.ownerPostCount = owner.forumStats.postCount;
r.ownerPostLikes = owner.forumStats.postLikes;
r.ownerTitle = owner.forumStats.title;
r.ownerTag = owner.forumStats.tag;
r.ownerImg = owner.forumStats.img;
return r;
},
ownerImgTab: function(){
return {src: this.ownerImg};
}
});
However, I am now facing another problem. Even tho I am restricting the fields I am publishing from the Users collection, it is still sending down the "services" field, that contains login data that shouldnt be sent, ideas?

Facebook FriendsList window not opening in Internet Explorer 8

I'm using the FB.UI() JavaScript SDK to get the selected friends id, when the user selects friends from Friendslist request dialog window.
The selected friends id is passed to a handler file.
The above situation is working fine in Firefox, that is, I am able to get the friends Id, but the same is not working in Internet Explorer 8.
In IE8, I am getting the error below when I click the button to open the friends request dialog.
API Error Code: 191 API Error Description: The specified URL is not
owned by the application Error Message: redirect_uri is not owned by
the application.
I had given the redirect_uri also but I'm not getting the friends id.
The code is given below:
function sendRequestToManyRecipients() {
alert("sendRequestToManyRecipients");
FB.ui({method: 'apprequests',
appId : '',
display: 'popup',
message: 'My Group'
}, requestCallback);
}
function requestCallback(response) {
getMultipleRequests(response.request_ids);
}
var friend=new Array();
var sfriend="";
function getMultipleRequests(request_ids)
{
if (response && request_ids)
{
var ids = request_ids;
var _batch = [];
for (var i = 0; i < ids.length; i++)
{
_batch.push({ "method": "get", "relative_url":ids[i] });
}
if (_batch.length > 0)
{
FB.api('/', 'POST', { batch: _batch }, function (res)
{
for (var j = 0; j < res.length; j++)
{
body = res[j].body;
var myObject = eval('(' + body + ')');
friendID = myObject.to.id;
friend[j]=friendID.toString();
}
});
}
}
showfriends();
}
function showfriends()
{
for (var i = 0; i < friend.length; i++)
{
sfriend=sfriend+","+friend[i].toString();
}
if(sfriend != null)
{
window.open("Friends.ashx?id="+sfriend,'WinName','width=900,height=500,left=200,top=200'); }
}
I'm searching for a solution but I am not able to find the correct one.
Does anyone have a solution to this?
Are you want to get the friend id that the user have sent in the apprequest dialog?
Consider using request 2.0 efficient, which can help you get the ids without calling another api after sending the request
I have answered a similar question before, please take a look:
how to get user id on facebook request dialog
updated: 2011-11-29
For your ref, I use this code before for a project on fb app, which works on both IE8, Firefox 7, chrome 15
FB.ui({
method : "apprequests",
title : "title",
message : "messafe!!",
display : "iframe"
},
inviteCallback
);
function inviteCallback(response) {
// Requests 2.0 Efficient
// {
// request: ‘request_id’
// to:[array of user_ids]
// }
if (response.request) {
var receiverIDs = response.to;
document.inviteForm.receivers.value = receiverIDs.join(",");
document.inviteForm.submit();
}
}

Resources