Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 02-12-2021, 11:56 AM   #1
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Cams - Chaturbate API V2 parsing via JavaScript

Have you wanted to build your own cams page from the Chaturbate API?

This is a little bit of code to help get you started.

It is based around Chaturbates API Version 2.

The biggest change between Version 1 and Version 2 was that Version 2 wants the client IP to be passed in on the API request. This allows Chaturbate to filter the results based on what cams they allow to be shown in what region.

With Version 1, the most common usage is to pull the results of the API server side and then cache it there, either as a file or in a database. Then dole out the results from the cache on each page hit. Typically you would do a pull from Chaturbate every 2-5 minutes to keep the cams fresh.

With Version 2, it is expected that you will pull from the API on every page hit with the client ip for filtering. This means that instead of hitting the API once every 2-5 minutes, you are hitting it on every page hit. This is considerably more overhead for your server to handle.

The solution? Move the API handling onto the client side. How do you do that? Using javascript and/or jquery.

The following code is the javascript I came up with to do the API call and parse in the client's browser. It has been tested in Chrome, Opera and Firefox. It is a simple little bit of code that for most practical uses must be expanded upon. It will work as is but really should have other things with it, things like a design and text, ya know? All those cool web things.

I am listing 2 different ways to pull in the API. The first is pure javascript, the second uses a jquery call to the AJAX object. To use the jquery version you need to include the jquery libraries. If you are already using jquery on your pages then it makes the most sense to use the jquery version. However, if you do not use jquery, are trying to keep your page load as low as possible, or are just a minimalist at heart, then you might want to use the pure javascript version.

Either way, there are 2 parts.

Part 1 is pull in the API data.

Part 2 is parse the API data and display it.

I have included some comments in the code to help you figure out what is happening but I left some for you to figure out yourself. I am including in here 2 working demos for you to view. Look under the sheets, play with the code.

The code is running from a .php file. You could almost do all of this with pure javascript but unfortunately you cannot get ahold of the user's ip in javascript. You either have to grab it from your server or from a 3rd party service. I decided that the best way to grab it was from my server and I use php to accomplish that. Since I am already in a php file I decided to utilize a little more code to make the solution a little more dynamic.

Have fun.

Code:
// Chaturbate API Version 2 
// xml feed pull and parse using javascript called from php

// by sarettah - Hatteras Designs 2021
// sarettah AT hatterasdesigns.com

// requires jquery libraries for the jquery ajax call
// could be done pure client side with the exception of the user ip.
// that would have to be called from a service or injected here as I did

// this section would go near the top of the page to make for easy editing
<?php 
  // edit area 
  $wmid='chaturbate webmaster Id';
  $tag='bigdick';    
  $gender='t';
  $limit=50;  
  $camsdiv='name of cams div';
  // end of edit area

  // construct the api url 
  $api_url="https://chaturbate.com/api/public/affiliates/onlinerooms/?wm=" . $wmid . "&format=xml&client_ip=" . $_SERVER['REMOTE_ADDR'];
  
  if($limit>0)
  {
    $api_url .="&limit=" . $limit;
  }
  if($tag>'')
  {
    $api_url .="&tag=" . $tag;
  }
  if($gender>'')
  {
    $api_url .="&gender=" . $genderl;
  }
?>

// Here are 2 different ways to pull in the xml feed into the page 
// both methods call the parse data function.
// Either of these would appear in your page somewhere after the cams div 
// Can be called inline in the page OR from the document ready function

// Pulling the xml page via pure javascript AJAX call
<script>
pathin="<?php echo $api_url; ?>";
if (window.XMLHttpRequest)
{
  dirpage=new XMLHttpRequest();
}
else
{
  dirpage=new ActiveXObject("Microsoft.XMLHTTP");
}
dirpage.onreadystatechange=function()
{
  if (dirpage.readyState==4 && dirpage.status==200)
  {
     parse_data(dirpage.responseText, "<?php echo $camsdiv; ?>");
  }
  dirpage.open("GET",pathin,true);
  dirpage.send();
}
</script>

// OR
//Pulling the xml page via a jquery AJAX call
<script>
      $.ajax({
        dataType: "html",
        url: "<?php echo $api_url; ?>",
        success: function (data) {
            //console.log(data);
            parse_data(data, "<?php echo $camsdiv; ?>");
        }
      });
</script>


<script>
// The parse data function parses the xml data and formats the cam element division.
// It then appends the result to the cams div

function parse_data(data, camsdiv)
{
  parser = new DOMParser();
  xmlDoc = parser.parseFromString(data,"text/xml");
  x=xmlDoc.getElementsByTagName("username");
  txt='';
  
  for (i = 0; i < x.length ;i++) 
  {
    // construct your cam element here
    // for example
    txt +='<div>';
    txt +='<a href=' + xmlDoc.getElementsByTagName("chatroom_url_revshare")[i].childNodes[0].nodeValue; 
    txt +='Username: ' + xmlDoc.getElementsByTagName("username")[i].childNodes[0].nodeValue + '<br>';
    txt +='<img src=' + xmlDoc.getElementsByTagName("image_url")[i].childNodes[0].nodeValue + '><br>';
    
    // use other xml elements from the api as needed..........
    // each element is called using the getelementsbytagname function and displaying their respective values
    
    txt +='</a>';
    txt +='</div>';
    
    // add the element to the div
    document.getElementById(camsdiv).innerHTML +=txt;
    txt='';
  }
}
</script>

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 12:01 PM   #2
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Example 1 - Using Javascript for the ajax api call:

https://madspiders.com/demo/cb_apiv2_demo1.php

Example 1 source code:

Code:
<?php 
  // edit area 
  $wmid='xxxxx';
  $tag='18';    
  $gender='f';
  $limit=32;  
  $camsdiv='camsdiv';
  // end of edit area

  // construct the api url 
  $api_url="https://chaturbate.com/api/public/affiliates/onlinerooms/?wm=" . $wmid . "&format=xml&client_ip=" . $_SERVER['REMOTE_ADDR'];
  
  if($limit>0)
  {
    $api_url .="&limit=" . $limit;
  }
  if($tag>'')
  {
    $api_url .="&tag=" . $tag;
  }
  if($gender>'')
  {
    $api_url .="&gender=" . $gender;
  }
?>
<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<meta http-equiv="content-type" content="text/html; charset=windows-1250">         
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example of pulling CB API Version 2</title>

<script>
function parse_data(data, camsdiv)
{
  parser = new DOMParser();
  xmlDoc = parser.parseFromString(data,"text/xml");
  x=xmlDoc.getElementsByTagName("username");
  txt='';
  
  for (i = 0; i < x.length ;i++) 
  {
    txt +='<div style="float:left;width:25%;margin-bottom:10px;padding:right:10px;text-align:center;">';
    txt +='<a rel=nofollow style="color:#000000;font-weight:bold;" href=' + xmlDoc.getElementsByTagName("chat_room_url_revshare")[i].childNodes[0].nodeValue + '>'; 
    txt +=xmlDoc.getElementsByTagName("username")[i].childNodes[0].nodeValue + '<br>';
    txt +='<img style="max-width:90%;" src=' + xmlDoc.getElementsByTagName("image_url")[i].childNodes[0].nodeValue + '><br>';
    txt +='</a>';
    txt +='</div>';
   
    document.getElementById(camsdiv).innerHTML +=txt;
    txt='';
  }
}
</script>
</head>
<body>
<div style="width:100%;text-align:center;">
<h1>Example of pulling Chaturbate API Version 2 using pure javascript</h1>
<br>
<div name="camsdiv" id="camsdiv" style="margin-left:15px;">
</div>
</div>
<script>
pathin="<?php echo $api_url; ?>";

if (window.XMLHttpRequest)
{
  dirpage=new XMLHttpRequest();
}
else
{
  dirpage=new ActiveXObject("Microsoft.XMLHTTP");
}
dirpage.onreadystatechange=function()
{
  if (dirpage.readyState==4 && dirpage.status==200)
  {
     parse_data(dirpage.responseText, "<?php echo $camsdiv; ?>");
  }
}
dirpage.open("GET",pathin,true);
dirpage.send();

</script>

</body>
</html>
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 12:02 PM   #3
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Example 2: Using jquery for the ajax api call:

https://madspiders.com/demo/cb_apiv2_demo2.php

Example 2 source code:

Code:
<?php 
  // edit area 
  $wmid='xxxxx';
  $tag='18';    
  $gender='f';
  $limit=32;  
  $camsdiv='camsdiv';
  // end of edit area

  // construct the api url 
  $api_url="https://chaturbate.com/api/public/affiliates/onlinerooms/?wm=" . $wmid . "&format=xml&client_ip=" . $_SERVER['REMOTE_ADDR'];
  
  if($limit>0)
  {
    $api_url .="&limit=" . $limit;
  }
  if($tag>'')
  {
    $api_url .="&tag=" . $tag;
  }
  if($gender>'')
  {
    $api_url .="&gender=" . $gender;
  }
?>
<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<meta http-equiv="content-type" content="text/html; charset=windows-1250">         
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example of pulling CB API Version 2</title>

<script src="//code.jquery.com/jquery-1.10.2.js"></script>

<script>
function parse_data(data, camsdiv)
{
  parser = new DOMParser();
  xmlDoc = parser.parseFromString(data,"text/xml");
  x=xmlDoc.getElementsByTagName("username");
  txt='';
  
  for (i = 0; i < x.length ;i++) 
  {
    txt +='<div style="float:left;width:25%;margin-bottom:10px;padding:right:10px;text-align:center;">';
    txt +='<a rel=nofollow style="color:#000000;font-weight:bold;" href=' + xmlDoc.getElementsByTagName("chat_room_url_revshare")[i].childNodes[0].nodeValue + '>'; 
    txt +=xmlDoc.getElementsByTagName("username")[i].childNodes[0].nodeValue + '<br>';
    txt +='<img style="max-width:90%;" src=' + xmlDoc.getElementsByTagName("image_url")[i].childNodes[0].nodeValue + '><br>';
    txt +='</a>';
    txt +='</div>';
   
    document.getElementById(camsdiv).innerHTML +=txt;
    txt='';
  }
}
</script>
</head>
<body>
<div style="width:100%;text-align:center;">
<h1>Example of pulling Chaturbate API Version 2 using javascript and AJAX</h1>
<br>
<div name="camsdiv" id="camsdiv" style="margin-left:15px;">
</div>
</div>

<script>
      $.ajax({
        dataType: "html",
        url: "<?php echo $api_url; ?>",
        success: function (data) {
            //console.log(data);
            parse_data(data, "<?php echo $camsdiv; ?>");
        }
      });
</script>

</body>
</html>
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 12:40 PM   #4
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
For the record the <base href tag is not actually part of the source code. GFY is inserting that into the post.

Code:
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 12:44 PM   #5
Paul&John
Confirmed User
 
Paul&John's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: YUROP
Posts: 8,592
sarettah to the rescue as always, big thumbs up ;)
__________________
Use coupon 'pauljohn' for a $1 discount at already super cheap NameSilo!
Anal Webcams | Kinky Trans Cams Live | Hotwife XXX Tube | Get your Proxies here
Paul&John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 12:50 PM   #6
fuzebox
making it rain
 
fuzebox's Avatar
 
Industry Role:
Join Date: Oct 2003
Location: seattle
Posts: 22,004
Nicely done
fuzebox is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 12:57 PM   #7
mechanicvirus
Confirmed User
 
mechanicvirus's Avatar
 
Industry Role:
Join Date: Feb 2005
Location: Southern California
Posts: 3,728
Great stuff, sarretah knows his shit.
mechanicvirus is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 02:30 PM   #8
CB Kitt
Registered User
 
CB Kitt's Avatar
 
Industry Role:
Join Date: Nov 2019
Posts: 7
Thanks for posting this. We encourage all affiliates to use the new API where possible.

FYI when calling from the client side, you do not need to pass the ip, you can just set it to "request_ip".

Please see our documentation (chaturbate[dot]com/affiliates/promotools/api_usersonline/) for more information.

__________________
Chaturbate Affiliate Support: [email protected]
CB Kitt is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 02:33 PM   #9
CaptainHowdy
Too lazy to set a custom title
 
CaptainHowdy's Avatar
 
Industry Role:
Join Date: Dec 2004
Location: Happy in the dark.
Posts: 92,975
We love you, sarettah . . . even though you hate us.
__________________
FLASH SALE INSANITY! deal with a 100% Trusted Seller
Buy Traffic Spots on a High-Quality Network

1 Year or Lifetime — That’s Right, Until the Internet Explodes!
CaptainHowdy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 02:37 PM   #10
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,224
Nice! I need to do more with cams, traffic for me has been going up.
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 02:58 PM   #11
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by CB Kitt View Post
Thanks for posting this. We encourage all affiliates to use the new API where possible.

FYI when calling from the client side, you do not need to pass the ip, you can just set it to "request_ip".

Please see our documentation (chaturbate[dot]com/affiliates/promotools/api_usersonline/) for more information.


Thanks for that. I will make a note of it.

Here is the link for the docs (You really need to post more there Kitt. Get up there above 30 posts so you can post links and show us your tits and all that). https://chaturbate.com/affiliates/pr...i_usersonline/

You need to be logged in to chaturbate to read the docs

Don't have a Chaturbate account? You can sign up here with my ref code https://www.camfoxes.com/webcams/webmaster_signup.htm

Or you can sign up directly at Chaturbate https://chaturbate.com/affiliates/

Bith links load real slow tright now so please be patient.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 03:10 PM   #12
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by CaptainHowdy View Post
We love you, sarettah . . . even though you hate us.
What?? When did I ever say I hated you (or anybody).

You are one of my favorite posters.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 03:24 PM   #13
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,224
Quote:
Originally Posted by sarettah View Post
Bith links load real slow tright now so please be patient.
The Chaturbate link in my sig loads faster, so I think people should use that one instead.
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 03:27 PM   #14
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Hmm. I was just putting together a new demo using the info that Kitt provided.

During testing I noticed that it loaded really slowly.

So, I went back and looked at the other 2 demos I posted and they are now seeming to take a while to load, about 15 seconds.

Earlier they were popping right in.

Don't know if the api is running slow or what the issue is.

I just know it was working fine and now it is a slow load.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 03:29 PM   #15
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,224
Quote:
Originally Posted by sarettah View Post
Hmm. I was just putting together a new demo using the info that Kitt provided.

During testing I noticed that it loaded really slowly.

So, I went back and looked at the other 2 demos I posted and they are now seeming to take a while to load, about 15 seconds.

Earlier they were popping right in.

Don't know if the api is running slow or what the issue is.

I just know it was working fine and now it is a slow load.

.
Some of the cams on the main site aren't loading right now, either. The splash comes up but then a constant spinning load animation. Then once in a while when I refresh, it loads but then like 3fps.
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 03:33 PM   #16
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Sample using just javascript - no php. Using request_ip in the client_ip parameter.

https://madspiders.com/demo/cb_apiv2_demo3.htm

Source:
Code:
<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<meta http-equiv="content-type" content="text/html; charset=windows-1250">         
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example of pulling CB API Version 2</title>

<script>
  // edit area 
  var wmid='xxxxx';
  var tag='18';    
  var gender='f';
  var limit=32;  
  var camsdiv='camsdiv';
  // end of edit area

  // construct the api url 
  api_url="https://chaturbate.com/api/public/affiliates/onlinerooms/?wm=" + wmid + "&format=xml&client_ip=request_ip";
  
  if(limit>0)
  {
    api_url +="&limit=" + limit;
  }
  if(tag>'')
  {
    api_url +="&tag=" + tag;
  }
  if(gender>'')
  {
    api_url +="&gender=" + gender;
  }
</script>
<script>
function parse_data(data, camsdiv)
{
  parser = new DOMParser();
  xmlDoc = parser.parseFromString(data,"text/xml");
  x=xmlDoc.getElementsByTagName("username");
  txt='';
  
  for (i = 0; i < x.length ;i++) 
  {
    txt +='<div style="float:left;width:25%;margin-bottom:10px;padding:right:10px;text-align:center;">';
    txt +='<a rel=nofollow style="color:#000000;font-weight:bold;" href=' + xmlDoc.getElementsByTagName("chat_room_url_revshare")[i].childNodes[0].nodeValue + '>'; 
    txt +=xmlDoc.getElementsByTagName("username")[i].childNodes[0].nodeValue + '<br>';
    txt +='<img style="max-width:90%;" src=' + xmlDoc.getElementsByTagName("image_url")[i].childNodes[0].nodeValue + '><br>';
    txt +='</a>';
    txt +='</div>';
   
    document.getElementById(camsdiv).innerHTML +=txt;
    txt='';
  }
}
</script>
</head>
<body>
<div style="width:100%;text-align:center;">
<h1>Example of pulling Chaturbate API Version 2 using just javascript</h1>
<br>
<div name="camsdiv" id="camsdiv" style="margin-left:15px;">
</div>
</div>

<script>
if (window.XMLHttpRequest)
{
  dirpage=new XMLHttpRequest();
}
else
{
  dirpage=new ActiveXObject("Microsoft.XMLHTTP");
}
dirpage.onreadystatechange=function()
{
  if (dirpage.readyState==4 && dirpage.status==200)
  {
     parse_data(dirpage.responseText, camsdiv);
  }
}
dirpage.open("GET",api_url,true);
dirpage.send();

</script>

</body>
</html>
As I said in the previous post, right now the api seems to be coming back slower than it has been. Still looking to see if it is my problem or on their end.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 03:44 PM   #17
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Colmike9 View Post
The Chaturbate link in my sig loads faster, so I think people should use that one instead.

Yeah but you aren't real well known for that thinking stuff.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 03:47 PM   #18
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,224
Quote:
Originally Posted by sarettah View Post
Yeah but you aren't real well known for that thinking stuff.

.
You're thinking of Colmike7
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 03:49 PM   #19
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Colmike9 View Post
You're thinking of Colmike7
I try not to think of any of you.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 03:50 PM   #20
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,224
Quote:
Originally Posted by sarettah View Post
I try not to think of any of you.

.
Still happens, tho
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 04:02 PM   #21
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
All the demos seem to be working fine now.

That is one of the problems of pulling teh api every hit, you become a slave to the api.

If the data from the api is stored on the server then you can reload the old data again when the api pull fails.

Might be a way to delay clearing the page on a hit so that you could check for a good return but I am not sure what that way would be at the moment. Have ot think on that.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 04:24 PM   #22
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
I just had a conversation with another programmer (whom I respect very much). He had seen the code and suggested a couple of changes in the .php versions of the code.

When getting the ip I was simply using the Server var for the Remote Ip ($_SERVER['REMOTE_ADDR']).

He suggested that for someone hosting with a forwarding service, such as cloudflare, that the Remote Addr var would always return Cloudflare's ip.

So to get to the real ip we have to do a little shuffling through the various server vars we have available and the code ends up looking something like:

Code:
  
  $clientip='';
  if (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_CLIENT_IP']);
  } 
  else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_X_FORWARDED_FOR']);
  } 
  else 
  {
    $clientip = addslashes($_SERVER['REMOTE_ADDR']);
  }
He also reminded me to always escape the server vars as a security step.

So I am changing up the 2 php demos to utilize this methodology.


Thanks to K0nr4d (https://gfy.com/members/k0nr4d/) for the advice. https://www.mechbunny.com/ is Konr4d's baby if you did not know that already.



.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 04:25 PM   #23
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
https://madspiders.com/demo/cb_apiv2_demo1.php

Demo 1 new source code:

Code:
<?php 
  // edit area 
  $wmid='JkjyU';
  $tag='18';    
  $gender='f';
  $limit=32;  
  $camsdiv='camsdiv';
  // end of edit area

  // pulling client ip 
  $client_ip='';
  if (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_CLIENT_IP']);
  } 
  else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_X_FORWARDED_FOR']);
  } 
  else 
  {
    $clientip = addslashes($_SERVER['REMOTE_ADDR']);
  }

  // construct the api url 
  $api_url="https://chaturbate.com/api/public/affiliates/onlinerooms/?wm=" . $wmid . "&format=xml&client_ip=" . $clientip;
  
  if($limit>0)
  {
    $api_url .="&limit=" . $limit;
  }
  if($tag>'')
  {
    $api_url .="&tag=" . $tag;
  }
  if($gender>'')
  {
    $api_url .="&gender=" . $gender;
  }
?>
<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<meta http-equiv="content-type" content="text/html; charset=windows-1250">         
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example of pulling CB API Version 2</title>

<script>
function parse_data(data, camsdiv)
{
  parser = new DOMParser();
  xmlDoc = parser.parseFromString(data,"text/xml");
  x=xmlDoc.getElementsByTagName("username");
  txt='';
  
  for (i = 0; i < x.length ;i++) 
  {
    txt +='<div style="float:left;width:25%;margin-bottom:10px;padding:right:10px;text-align:center;">';
    txt +='<a rel=nofollow style="color:#000000;font-weight:bold;" href=' + xmlDoc.getElementsByTagName("chat_room_url_revshare")[i].childNodes[0].nodeValue + '>'; 
    txt +=xmlDoc.getElementsByTagName("username")[i].childNodes[0].nodeValue + '<br>';
    txt +='<img style="max-width:90%;" src=' + xmlDoc.getElementsByTagName("image_url")[i].childNodes[0].nodeValue + '><br>';
    txt +='</a>';
    txt +='</div>';
   
    document.getElementById(camsdiv).innerHTML +=txt;
    txt='';
  }
}
</script>
</head>
<body>
<div style="width:100%;text-align:center;">
<h1>Example of pulling Chaturbate API Version 2 using pure javascript</h1>
<br>
<div name="camsdiv" id="camsdiv" style="margin-left:15px;">
</div>
</div>
<script>
pathin="<?php echo $api_url; ?>";

if (window.XMLHttpRequest)
{
  dirpage=new XMLHttpRequest();
}
else
{
  dirpage=new ActiveXObject("Microsoft.XMLHTTP");
}
dirpage.onreadystatechange=function()
{
  if (dirpage.readyState==4 && dirpage.status==200)
  {
     parse_data(dirpage.responseText, "<?php echo $camsdiv; ?>");
  }
}
dirpage.open("GET",pathin,true);
dirpage.send();

</script>

</body>
</html>
.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 04:26 PM   #24
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
https://madspiders.com/demo/cb_apiv2_demo2.php

Demo 2 new source code:

Code:
<?php 
  // edit area 
  $wmid='JkjyU';
  $tag='18';    
  $gender='f';
  $limit=32;  
  $camsdiv='camsdiv';
  // end of edit area
  // pulling client ip 

  $client_ip='';
  if (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_CLIENT_IP']);
  } 
  else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_X_FORWARDED_FOR']);
  } 
  else 
  {
    $clientip = addslashes($_SERVER['REMOTE_ADDR']);
  }

  // construct the api url 
  $api_url="https://chaturbate.com/api/public/affiliates/onlinerooms/?wm=" . $wmid . "&format=xml&client_ip=" . $clientip;
  
  if($limit>0)
  {
    $api_url .="&limit=" . $limit;
  }
  if($tag>'')
  {
    $api_url .="&tag=" . $tag;
  }
  if($gender>'')
  {
    $api_url .="&gender=" . $gender;
  }
?>
<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<meta http-equiv="content-type" content="text/html; charset=windows-1250">         
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Example of pulling CB API Version 2</title>

<script src="//code.jquery.com/jquery-1.10.2.js"></script>

<script>
function parse_data(data, camsdiv)
{
  parser = new DOMParser();
  xmlDoc = parser.parseFromString(data,"text/xml");
  x=xmlDoc.getElementsByTagName("username");
  txt='';
  
  for (i = 0; i < x.length ;i++) 
  {
    txt +='<div style="float:left;width:25%;margin-bottom:10px;padding:right:10px;text-align:center;">';
    txt +='<a rel=nofollow style="color:#000000;font-weight:bold;" href=' + xmlDoc.getElementsByTagName("chat_room_url_revshare")[i].childNodes[0].nodeValue + '>'; 
    txt +=xmlDoc.getElementsByTagName("username")[i].childNodes[0].nodeValue + '<br>';
    txt +='<img style="max-width:90%;" src=' + xmlDoc.getElementsByTagName("image_url")[i].childNodes[0].nodeValue + '><br>';
    txt +='</a>';
    txt +='</div>';
   
    document.getElementById(camsdiv).innerHTML +=txt;
    txt='';
  }
}
</script>
</head>
<body>
<div style="width:100%;text-align:center;">
<h1>Example of pulling Chaturbate API Version 2 using javascript and AJAX</h1>
<br>
<div name="camsdiv" id="camsdiv" style="margin-left:15px;">
</div>
</div>

<script>
      $.ajax({
        dataType: "html",
        url: "<?php echo $api_url; ?>",
        success: function (data) {
            //console.log(data);
            parse_data(data, "<?php echo $camsdiv; ?>");
        }
      });
</script>

</body>
</html>
.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 06:24 PM   #25
CaptainHowdy
Too lazy to set a custom title
 
CaptainHowdy's Avatar
 
Industry Role:
Join Date: Dec 2004
Location: Happy in the dark.
Posts: 92,975
Quote:
Originally Posted by sarettah View Post
What?? When did I ever say I hated you (or anybody).

You are one of my favorite posters.

.
__________________
FLASH SALE INSANITY! deal with a 100% Trusted Seller
Buy Traffic Spots on a High-Quality Network

1 Year or Lifetime — That’s Right, Until the Internet Explodes!
CaptainHowdy is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 07:30 PM   #26
fuzebox
making it rain
 
fuzebox's Avatar
 
Industry Role:
Join Date: Oct 2003
Location: seattle
Posts: 22,004
Quote:
Originally Posted by sarettah View Post
I just had a conversation with another programmer (whom I respect very much). He had seen the code and suggested a couple of changes in the .php versions of the code.

When getting the ip I was simply using the Server var for the Remote Ip ($_SERVER['REMOTE_ADDR']).

He suggested that for someone hosting with a forwarding service, such as cloudflare, that the Remote Addr var would always return Cloudflare's ip.

So to get to the real ip we have to do a little shuffling through the various server vars we have available and the code ends up looking something like:

Code:
  
  $clientip='';
  if (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_CLIENT_IP']);
  } 
  else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_X_FORWARDED_FOR']);
  } 
  else 
  {
    $clientip = addslashes($_SERVER['REMOTE_ADDR']);
  }
He also reminded me to always escape the server vars as a security step.

So I am changing up the 2 php demos to utilize this methodology.


Thanks to K0nr4d (https://gfy.com/members/k0nr4d/) for the advice. https://www.mechbunny.com/ is Konr4d's baby if you did not know that already.



.
Cloudflare has their own headers for you to substitute into your code. REMOTE_ADDR is HTTP_CF_CONNECTING_IP.
fuzebox is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 07:54 PM   #27
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by fuzebox View Post
Cloudflare has their own headers for you to substitute into your code. REMOTE_ADDR is HTTP_CF_CONNECTING_IP.
Thanks WOTY

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-12-2021, 10:12 PM   #28
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
So based on what Fuzebox said, if you are hosting on cloudflare and were doing this with php you would want to check for Cloudflare's custom server var (HTTP_CF_CONNECTING_IP) for handling the ip.

Code:
  $clientip='';

  if (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && $_SERVER['HTTP_CF_CONNECTING_IP'] != "")
  {
    $clientip = addslashes($_SERVER['HTTP_CF_CONNECTING_IP']);
  }
  elseif (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_CLIENT_IP']);
  } 
  else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != "") 
  {
    $clientip = addslashes($_SERVER['HTTP_X_FORWARDED_FOR']);
  } 
  else 
  {
    $clientip = addslashes($_SERVER['REMOTE_ADDR']);
  }
.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-13-2021, 01:33 AM   #29
Paul&John
Confirmed User
 
Paul&John's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: YUROP
Posts: 8,592
Quote:
Originally Posted by CB Kitt View Post
Thanks for posting this. We encourage all affiliates to use the new API where possible.

FYI when calling from the client side, you do not need to pass the ip, you can just set it to "request_ip".

Please see our documentation (chaturbate[dot]com/affiliates/promotools/api_usersonline/) for more information.

Any plans for disabling API v1?
__________________
Use coupon 'pauljohn' for a $1 discount at already super cheap NameSilo!
Anal Webcams | Kinky Trans Cams Live | Hotwife XXX Tube | Get your Proxies here
Paul&John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-13-2021, 04:01 AM   #30
Andreweb
Confirmed User
 
Andreweb's Avatar
 
Industry Role:
Join Date: Mar 2013
Location: Internet
Posts: 2,425
Sarettah you are the best! Thank you for sharing this with us! You already helped me and other people a lot around here
__________________
Make Money With: Chaturbate
Andreweb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-13-2021, 04:28 AM   #31
Fred - Nexturbate
Confirmed User
 
Fred - Nexturbate's Avatar
 
Industry Role:
Join Date: Mar 2019
Posts: 89
Can you tell me what is the advantage of using API version 2? Because version 1 is quite functional, and there is no such "problem" with ip.
Thank you
Fred - Nexturbate is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-13-2021, 07:40 AM   #32
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Fred - Nexturbate View Post
Can you tell me what is the advantage of using API version 2? Because version 1 is quite functional, and there is no such "problem" with ip.
Thank you
First of all the disclaimer: I am NOT an employee of Chaturbate, I am an affiliate just like the rest of you.

I do not know what advantages Chaturbate intended on v2 versus v1.

I can tell you the advantages I see, but it will be totally from my perspective.

V1 was never really (imho) intended to be pulled on every hit. It returns all cams every time you call it. Each time it is called you have to process through the entire set of cams to do the various things you want to do.

V2 allows several passins that limit the return set.

limit= controls the number of records coming back
offset= controls where in the return set to start
exhibitionist= I am not sure what that will do, have not explored it yet,
gender= allows you to select a single gender or all genders
region= allows you to return cams for just a certain region
tag= returns records for certain tags
hd= returns records for hd cams

Then there is the client_ip parameter. This allows Chaturbate to filter based on a performers setting whether the cam should appear in the set based on the users country or locality. Version 1 has a field for countries allowed but it has always been empty. If it was filled it would have been up to you to do a lookup by ip to see if the user on your site should see the cam or not. This should eliminate some of the issues of putting a cam up and when you click it coming back saying that you are not allowed to see it.

These new parameters allow you to more finitely control the return set. It also allows the api to be much more efficient in that it does not have to be returning as many records and you don't have to handle as many records. So, with V2 you can realistically call it on every hit and still have a fast site.

There are disadvantages too. With Version 2 it is harder to do certain things. For example, I have several sites that are based off the age of the model (18yearoldcams, 1821camgirls, milffoxes(coming)). To do those with V2, using it the way it is intended, would be a major pain in the ass as there is no pass in to return just certain age cams. I would have to circumvent what Chaturbate wants to do and still use V2 like it was V1, pulling it into the database so that I could spit out just the cams I want.

I also like to do certain sorts. By age, location, etc. Doing these effectively with V2 would be another PITA. You would have to pull in all cams, sort them and then present the proper set. So again, I would probably be circumventing Chaturbate's intended use of V2 and instead use it as I use V1 and load it all to a database every 5 minutes.

Another disadvantage showed itself yesterday. While I was making this thread, the api slowed down for some reason. This made all my demos break basically. I don't have to worry about that on the sites I am loading using V1. On those I load a database. If the API does not return for me I just use the old set of cams until the API comes back. I am never without cams. That is not true if you are using V2 on every hit. On V2, you are basically presenting what is in the api return, no api return, no cams. I am sure there will be workarounds to handle that but using it as intended, there is not.

I think V1 will still has it's place and there are so many sites using it that I doubt that Chaturbate will be turning it off anytime soon. I have a note in Chaturbate right now asking if they have a planned end of life date on V1 as I use it all over the place.

That is my take on it for what it is worth and I guarantee that it is worth every cent you paid for it.

Edited in: I forgot to list what might be the biggest advantage although I did mention it in the OP. With V2 you can create a workable client side only solution. V1 did not really allow that because of the overhead involved in handling all the cams on every api call. Since you can limit the number of cams on V2 through the various passins you can create a client side solution that works. This moves a shitload of infrastructure and bandwidth off of your server and on to the client. This should result in lower costs and more efficient page delivery.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-13-2021, 02:38 PM   #33
Colmike9
(>^_^)b
 
Colmike9's Avatar
 
Industry Role:
Join Date: Dec 2011
Posts: 7,224
Quote:
Originally Posted by sarettah View Post
exhibitionist= I am not sure what that will do, have not explored it yet,

.
I heard that those are accounts who just want to show off and not asking for tips. Seems weird lol.
*I also heard it was for accounts that are also not age verified yet, which also seemed weird. Maybe the article I read is wrong, idk.
__________________
Join the BEST cam affiliate program on the internet!
I've referred over $1.7mil in spending this past year, you should join in.
I make a lot more money in the medical field in a lab now, fuck you guys. Don't ask me to come back, but do join Chaturbate in my sig, it still makes bank without me touching shit for years..
Colmike9 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-13-2021, 04:27 PM   #34
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Colmike9 View Post
I heard that those are accounts who just want to show off and not asking for tips. Seems weird lol.
*I also heard it was for accounts that are also not age verified yet, which also seemed weird. Maybe the article I read is wrong, idk.
Not sure but I did a test a few minutes ago. Set limit to 10 and set exhibitionist to true, got 1 record back.

So, of all the thousands of cams on line at that time only 1 was marked exhibitionist so I don't know that the parameter is significant.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 03:00 AM   #35
Paul&John
Confirmed User
 
Paul&John's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: YUROP
Posts: 8,592
Quote:
Originally Posted by sarettah View Post
Another disadvantage showed itself yesterday. While I was making this thread, the api slowed down for some reason. This made all my demos break basically. I don't have to worry about that on the sites I am loading using V1. On those I load a database.
I have a few cam sites using the API for each request so they use no database at all. Can such sites be theoretically faster then using a site + local sql database? Or only in cases when my server is really shitty slow or gets a ton of request and can't handle them properly?
One of my best performing site in search engines gets data from the API alone, so no local caching etc.
__________________
Use coupon 'pauljohn' for a $1 discount at already super cheap NameSilo!
Anal Webcams | Kinky Trans Cams Live | Hotwife XXX Tube | Get your Proxies here
Paul&John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 06:03 AM   #36
redwhiteandblue
Bollocks
 
redwhiteandblue's Avatar
 
Industry Role:
Join Date: Jun 2007
Location: Bollocks
Posts: 2,792
Quote:
Originally Posted by sarettah View Post
Another disadvantage showed itself yesterday. While I was making this thread, the api slowed down for some reason. This made all my demos break basically. I don't have to worry about that on the sites I am loading using V1. On those I load a database. If the API does not return for me I just use the old set of cams until the API comes back. I am never without cams. That is not true if you are using V2 on every hit. On V2, you are basically presenting what is in the api return, no api return, no cams. I am sure there will be workarounds to handle that but using it as intended, there is not.
.
If you're using v2 to pull into a database, what IP do you use? The server IP?

I notice a distinct delay on my webcam page using API v2, of about 2 seconds or more - and I'm only getting a list of 40 cams. I want to eliminate this by going to a database driven approach, only trouble is my site is aimed more at UK and European visitors so those are the cams I pull out of the API, but my server is in the US. So that's not ideal.
redwhiteandblue is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 08:59 AM   #37
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Paul&John View Post
I have a few cam sites using the API for each request so they use no database at all. Can such sites be theoretically faster then using a site + local sql database? Or only in cases when my server is really shitty slow or gets a ton of request and can't handle them properly?
One of my best performing site in search engines gets data from the API alone, so no local caching etc.
My guess is that it would definitely be possible for a site just using the api to be as fast or faster than a site pulling the whole thing into the database.

First of all there are efficient ways to do things and inefficient ways. If someone has coded the api call and parse propely and is doing pagination then that could be a very fast site. However if they are doing just the api and trying to present all the cams all at once then it will probably be a slow load.

On the server side solution, the database has to be designed properly and the sql calls need to be coded properly. Just because something is in a database does not mean it is fast or efficient.

There is a lot of shitty code out there, I know because I have written some of it.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 09:02 AM   #38
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by redwhiteandblue View Post
If you're using v2 to pull into a database, what IP do you use? The server IP?

I notice a distinct delay on my webcam page using API v2, of about 2 seconds or more - and I'm only getting a list of 40 cams. I want to eliminate this by going to a database driven approach, only trouble is my site is aimed more at UK and European visitors so those are the cams I pull out of the API, but my server is in the US. So that's not ideal.

I have not played with v2 on the server side so I am not sure what the best workaround would be yet. My gut instinct would be to hardcode my home ip in the client_ip field and use it that way but without playing with it some I could not give you a good answer.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 09:22 AM   #39
k33n
Confirmed User
 
Join Date: Feb 2009
Posts: 201
Quote:
Originally Posted by redwhiteandblue View Post
If you're using v2 to pull into a database, what IP do you use? The server IP?
0.0.0.0 to avoid geo IP filter
k33n is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 09:31 AM   #40
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by k33n View Post
0.0.0.0 to avoid geo IP filter
That would appear to work. Thanks for that

So, redwhiteandblue, there is your answer.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 09:34 AM   #41
Paul&John
Confirmed User
 
Paul&John's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: YUROP
Posts: 8,592
Quote:
Originally Posted by sarettah View Post
My guess is that it would definitely be possible for a site just using the api to be as fast or faster than a site pulling the whole thing into the database.

First of all there are efficient ways to do things and inefficient ways. If someone has coded the api call and parse propely and is doing pagination then that could be a very fast site. However if they are doing just the api and trying to present all the cams all at once then it will probably be a slow load.

On the server side solution, the database has to be designed properly and the sql calls need to be coded properly. Just because something is in a database does not mean it is fast or efficient.

There is a lot of shitty code out there, I know because I have written some of it.

.
Yeah I'm definitely calling the API with limit+page and tags where needed (subcategory pages). It's pretty fast..
__________________
Use coupon 'pauljohn' for a $1 discount at already super cheap NameSilo!
Anal Webcams | Kinky Trans Cams Live | Hotwife XXX Tube | Get your Proxies here
Paul&John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 09:59 AM   #42
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Paul&John View Post
Yeah I'm definitely calling the API with limit+page and tags where needed (subcategory pages). It's pretty fast..
You are talking about API V2 then?

I thought you were talking about V1. But with V2, yeah, definitely can make a site run faster then going into a database or caching scheme. Less infrastructure to deal with. Less steps involved.

I am going to set up dudefoxes using full client side javascript. Only call back to the server will be the click into the cams because I want to hit my tracking script (oh and the logo and crap like that).

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 12:06 PM   #43
Paul&John
Confirmed User
 
Paul&John's Avatar
 
Industry Role:
Join Date: Aug 2005
Location: YUROP
Posts: 8,592
No-no, I'm talking about AWEs Video Promo API.. I havent checked CHBs API v2 yet
__________________
Use coupon 'pauljohn' for a $1 discount at already super cheap NameSilo!
Anal Webcams | Kinky Trans Cams Live | Hotwife XXX Tube | Get your Proxies here
Paul&John is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 01:02 PM   #44
Shoplifter
Richest man in Babylon
 
Shoplifter's Avatar
 
Industry Role:
Join Date: Jan 2002
Location: Posts: 10,002
Posts: 5,678
@sarettah this is very cool and wicked fast.

How could chat_room_url_revshare and image_url be modified to reflect a white label URL without slowing it down?

Otherwise adblock.
Shoplifter is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 01:48 PM   #45
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Shoplifter View Post
@sarettah this is very cool and wicked fast.

How could chat_room_url_revshare and image_url be modified to reflect a white label URL without slowing it down?

Otherwise adblock.
You shouldn't have to touch image_url. From what I see it is the chat_room_url that triggers the block.

You can modify the Chat room url ot pull from a whitelabel by just using:

Whitelabel + Username

So something like this (using my whitelabel at Hot Foxes at Camfoxes.net to link to):

txt +='<a rel=nofollow style="color:#000000;font-weight:bold;" href=https://www.camfoxes.net/' + xmlDoc.getElementsByTagName("username")[i].childNodes[0].nodeValue + '>';

Where I was using the chat room url from the feed before.

This appears to get past my adblockers and works on opera with ad blocking turnded on no problem:

https://madspiders.com/demo/cb_apiv2_demo4.htm

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 01:49 PM   #46
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by Paul&John View Post
No-no, I'm talking about AWEs Video Promo API.. I havent checked CHBs API v2 yet
Ah, when you mentioned limit and tags I just assumed. My bad.

Thanks

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-14-2021, 03:53 PM   #47
Shoplifter
Richest man in Babylon
 
Shoplifter's Avatar
 
Industry Role:
Join Date: Jan 2002
Location: Posts: 10,002
Posts: 5,678
Thanks Sarettah.

As a learning project I intend to use this to replace the WP Live Cam Wordpress theme I have running on a domain and it's huge Gigabyte size DB....
Shoplifter is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-15-2021, 08:36 AM   #48
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
I started in on 2 new sites yesterday using the pure javascript version.

Still have to do up some text and change up colors and shit but they are up and running.

https://dudefoxes.com

https://milffoxes.com


Still have to doctor them up for mobile too.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-15-2021, 03:37 PM   #49
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Figured out the pagination today. Works pretty slick.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 02-15-2021, 03:38 PM   #50
nikki99
Supermodel
 
nikki99's Avatar
 
Industry Role:
Join Date: Nov 2004
Location: Sodoma & Gomorra
Posts: 22,831
2 pages of cams
nikki99 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
api, page, version, jquery, javascript, code, pull, call, cams, data, pure, function, chaturbate, parse, xml, ajax, server, client, php, hit, results, file, feed, called, figure
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.