View Single Post
Old 02-12-2021, 03:33 PM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,057
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