Greenguy's Board


Go Back   Greenguy's Board > General Business Knowledge
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2021-03-12, 09:25 AM   #1
sarettah
Asleep at the switch? I wasn't asleep, I was drunk
 
Join Date: Apr 2005
Posts: 214
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>
sarettah is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:15 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc