Hello I am working on a project that requires me to track pages using first promoter.
see below api documentation
https://docs.firstpromoter.com/#api-reference
what i need to do is get the present cookie of the website and pass the "vistior tracking id" as below using the link and js.
https://######.com?fpr=testvstihyao&test_mode=1`
<script>(function(w){w.fpr=w.fpr||function(){w.fpr.q = w.fpr.q||[];w.fpr.q[arguments[0]=='set'?'unshift':'push'](arguments);};})(window);
fpr("init", {cid:"######"});
fpr("click");
</script>
<script src="https://cdn.firstpromoter.com/fpr.js" async></script>
<script>
var x = document.cookie;
window.alert(x);
</script>
also see screenshots of request made
enter image description here
and then I make a request to using first promoters documentation as below
enter image description here
so everything works while testing.
But when i try to track my page like this https://######.com?fpr=dee. (without the test mode i am unable to get a tid which I am supposed to use to make an api request.
I was expecting to get the tid when i tried to access the cookie with the tesmode parameter
I must be missing something, please help
Related
This is my code:
function myFunction() {
var test = DocumentApp.openById('someid');
test.clear();
var html = UrlFetchApp.fetch('https://www.crunchbase.com/organization/google').getContentText();
test.appendParagraph(html);
}
Request failed for
https://www.crunchbase.com/organization/google returned code
416. Truncated server
How to fix this? When I set the website as www.google.com it works, but fails when I set to https://www.crunchbase.com/organization/google.
that's because crunchbase.com do not allow robot to crawl their site.
To avoid the error in your script you need to add muteHttpExceptionsparameter to your urlfetch request:
var params = {muteHttpExceptions:true};
var response = UrlFetchApp.fetch('https://www.crunchbase.com/organization/google',params);
var html = response.getContentText();
test.appendParagraph(html);
then you'll be able to see the response :
Pardon Our Interruption
Pardon Our Interruption...
As you were browsing http://www.crunchbase.com something about your
browser made us think you were a bot. There are a few reasons this
might happen:
You're a power user moving through this website with super-human speed.
You've disabled JavaScript in your web browser.
A third-party browser plugin, such as Ghostery or NoScript, is preventing JavaScript from running. Additional
information is available in this http://ds.tl/help-third-party-plugins'
target='_blank'>support article.
To request an unblock, please fill out the form below and we will review it as soon as possible.
<form id="zwxrztubr" method="POST" action="rytxecbxwsecazdrftrytxe.html"
style="display:none">Ignore: Ignore: Ignore:
First Name
Last Name
E-mail
City
Request Unblock
You reached this page when attempting to access http://www.crunchbase.com/organization/google from 107.178.192.142 on
2016-08-31 07:38:18 GMT.
Trace: E2A843FA-6F4D-11E6-B2D7-9FC6DA1DE14E via c17ee8fd-4346-4832-a021-e5f8124f2861
I am new to web development and am trying to make a very simple search page that displays YouTube videos using the YouTube API. I've been following the examples from here: https://developers.google.com/youtube/v3/code_samples/javascript?hl=fr#search_by_keyword
but I'm not having a lot of luck. I have no errors but no search results either.
My current code is here: http://amalthea5.github.io/thinkful-tube/
There seems to be several problems.
You need to use
<script src="https://apis.google.com/js/client.js?onload=googleApiClientReady"></script>
instead of
<script src="https://apis.google.com/js/client.js?onload=onClientLoad" type="text/javascript"></script>
because you need to make sure the initialization function googleApiClientReady() in auth.js is called.
However, the Google API also reports that there exists no OAuth client with the ID trusty-sentinel-92304.
Edit:
If don't have an OAuth client ID, but rather an API key, you shouldn't use the auth API at all. Instead, you need to add the API key as parameter to each API call (as described here: https://developers.google.com/youtube/v3/docs/standard_parameters).
Try this as a start:
gapi.client.load('youtube', 'v3', function() {
var request = gapi.client.youtube.search.list({
key: "YOUR_API_KEY",
q: "cats",
part: 'snippet'
});
request.execute(function(response) {
var str = JSON.stringify(response.result);
console.log(str);
});
});
To begin with if you read the very tutorial you are following again, it says that:
Again, you need to update the client ID in the auth.js file to run this code.
Which looks like you didnt,
also by running a search query from the console I get the following error:
TypeError: gapi.client.youtube is undefined
Meaning the api is not initiated, You should double check the way you embed the google javascript file and the priority of doing so (the order of them)
I want to get the title of a webpage without opening it, i.e. without using window.open().
I basically want to check whether the page i am providing the link for exists or an error is returned.
What I am trying is checking for similar links. Here is the code
(I want to know when to break out of this loop, i.e. at what point the link I am writing exists).
document.getElementById("TOI").innerHTML="<p>";
if (month<10) var m="0"+month;
else var m=month;
for(var i=1;;i++){
alert("ji");
var a="http://epaper.timesofindia.com/Repository/CAP/"+year+"/"+m+"/"+date+"/CAP_"+year+"_"+month+"_"+date+"_"+i+".pdf";
alert(a);
var link=window.open(a);
window.focus();
alert(link.location);
alert(link.document.title);
if(link.document.title!="The page cannot be found"){
link.close();
document.getElementById("TOI").innerHTML=document.getElementById("TOI").innerHTML+"<a href='http://epaper.timesofindia.com/Repository/CAP/"+year+"/"+m+"/"+date+"/CAP_"+year+"_"+month+"_"+date+"_"+i+".pdf' target=_blank>Page "+i+"</a> ";
}
else{link.close();break;}
}
document.getElementById("TOI").innerHTML=document.getElementById("TOI").innerHTML+"<\p>";
}
See to check if a url exists or not, you must use a server-side scripting language. Javascript is client-side and can't access server. So, first of all make a server side script (maybe php) that returns the status of url that you wanna check. Then from javascript side, use an ajax call to get the result of that script. That way you can check your url array, if all of them exists or not.
var attribute = element.getAttribute("title");
I want to get title of a webpage
without opening it(that is without
using window.open()) I basically want
to check whether the page i am
providing the link for exists or an
error is returned
Just because a page has a title doesn't mean it exists.
http://www.google.com/thispagedoesnotexist.htm
Examine HTTP status codes rather than page titles:
Can Prototype or JQuery return an HTTP status code on an AJAX request
Any idea?
I checked the Youtube API that doesn't support this feature.
Is it possible?
I need to get the thumbnail picture via username directly.
for example:
I got a username named: communitychannel
and I want to get the following thumbnail picture:
http://i2.ytimg.com/vi/YVrqydZz3e4/default.jpg
Thanks your reply!!
I know I can retrieve thumbnail data by doing this. But the case is, I will get a Youtube member's subscription item list first via the following URL:
http://gdata.youtube.com/feeds/api/users/[USER_NAME]/subscriptions
From the Youtube official document, it indicate that the response data include tag. But I never see it...
If list length is 100, then I need to send total 101 requests to get the thumbnail data for each item. But it will consume too much network bandwidth to do that.
So, is any other way to accomplish the requirement? Thanks!! ;-)
You can get the users image by using a url like this:
http://gdata.youtube.com/feeds/api/users/communitychannel
You can get just the username and image thumbnail by appending a query string as described in the
partial responses api:
?fields=yt:username,media:thumbnail
You can get the response in json format to use easily in javascript by appending:
&alt=json-in-script&format=5
You can also specify a callback to execute when the response has loaded by appending: &callback=showImage
Your url now looks like this:
http://gdata.youtube.com/feeds/api/users/communitychannel?fields=yt:username,media:thumbnail&alt=json-in-script&format=5&callback=showImage
To use this in a page put it in a script tag like so:
<script type='text/javascript' src="your_url"/>
and the callback should look like this:
function showImage(data)
{
var name= data.entry.yt$username.$t;
var url = data.entry.media$thumbnail.url;
$(document).append("<img src='"+ url +"'/>");
}
You must make sure that the showImage callback function is defined before you load the data.
I have created a sample of loading a feed and the user images here (Make sure you change communitychannel to your own username or it won't work)
I can't see a better way of reducing your bandwidth than using the partial responses api;
I have very little experience with web development. I have a little experience with HTML and I am learning JavaScript right now. I created a program in Java using a a last.fm library for Java. I was able to get user information, artist information, and venue information. Now I want to try and do that in a webpage, which is where my problem occurs.
I'm using the javascript last.fm api given here http://github.com/fxb/javascript-last.fm-api
I've downloaded all the .js files and they are in the same directory as my .htm file.
This is my code so far.
<html>
<body>
<script type="text/javascript" src="lastfm.api.md5.js"></script>
<script type="text/javascript" src="lastfm.api.js"></script>
<script type="text/javascript" src="lastfm.api.cache.js"></script>
<script type="text/javascript">
var cache = new LastFMCache();
var lastfm = new LastFM({
apiKey : 'c9946d11aaaaaaaaaaaaaaaaaaaaaaaace',
apiSecret : '9dabf9aaaaaaaaaaaaaaaaxxx11ec3c7a993',
cache : cache
});
lastfm.artist.getInfo({artist: 'The xx'}, {success: function(data){
/* Use Data */
}, error: function(code, message){
/* Show error message. */
}});
</script>
</body>
</html>
I've dug around in the included .js files to try and understand what is going on. So on my initialization of lastfm, I am passing in some objects with associated values, which are then applied to lastfm. If I try and access them through document.write(lastfm.apiKey) I get an undefined value, which I don't really understand.
Also I see that I am calling getInfo and passing in 'The xx' and everything that follows. I don't understand how to use that Data that I believe is returned as a JSON response. How can I print the bio that is associated with that artist?
the code that should go where you have written /* Use Data */ will refer to items such as data.bio. Try alert(data) to see what's in there.
I would also highly recommend using a JavaScript debugging console such as FireBug in order to really see what's going on.
i just used this, and yeah. you just need to console.log(data) in the success to get info about the data that is being passed back from last fm