Tech Cams - Chaturbate API V2 parsing via JavaScript
Good morning Greenguys denizens. First, I would like to apologize for sometimes forgetting to come visit and post over here. No excuse, shit happens.
I was trying to think of what I could post that would be helpful to folks over here. I decided to post something that I posted at the Zoo about a month ago. For those of you who still visit the Zoo, you will have seen this before. For those that no longer make it over there, I hope this is helpful to you. --------------------------------------------------------------------------- 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 . |
Example 1 - Using Javascript for the ajax api call:
https://madspiders.com/demo/cb_apiv2_demo1.php Example 1 source code: Code:
// edit area |
Example 2: Using jquery for the ajax api call:
https://madspiders.com/demo/cb_apiv2_demo2.php Example 2 source code: Code:
// edit area |
Narrator comment:
In the ooriginal Zoo thread, Kitt from Chaturbate posted a comment to me that is quite pertyinent so I will quote it here: Quote:
Here is the link for the docs 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/ [/quote] |
Sample using just javascript - no php. Using request_ip in the client_ip parameter.
https://madspiders.com/demo/cb_apiv2_demo3.htm Source: Code:
|
Narrator comment: After I had posted the samples, a friend told me some stuff:
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:
So I am changing up the 2 php demos to utilize this methodology. Thanks to K0nr4d for the advice. https://www.mechbunny.com/ is Konr4d's baby if you did not know that already. . |
https://madspiders.com/demo/cb_apiv2_demo1.php
Demo 1 new source code: Code:
// edit area |
https://madspiders.com/demo/cb_apiv2_demo2.php
Demo 2 new source code: Code:
// edit area |
I did up 2 live sites using the pure javascript version.
https://dudefoxes.com https://milffoxes.com Feel free to look under the sheets. That's all I have for now. I hope some of you find this useful. I will try to be more active on the board going forward but I will not promise anything. I believe that I have said that before, probably multiple times on multiple boards. . |
Thanks for putting all that in.
I keep saying I'm going to try doing this but get lazy and just slap the iframe where I want it. If I finally get around to it I know this is here |thumb |
Quote:
Easy to use it to make a little widget of 3 or 4 or 10 cams. . |
Quote:
2 - DAMN! THANK YOU!!! |
Really useful stuff.
We must be using the old API. Is that why monthly checks have gone to...still waiting after 3 months of next to no sales? |
Quote:
Most of my sites still run the old API. . |
Quote:
A lot of people are talking about it. Models overlays are an issue for one. What else? Models inviting people to sign up again is another. We've reported a few to CB. |
Quote:
I know that a lot of people have been saying that their numbers are down and I really cannot offer any real enlightenment on the issue. I do know that my traffic is mostly from google and the biggest effect on how well I do in sign ups is the positions I have in G. If I am getting lots of keywords in the 1-3 positions then I get lots of signups. If I drop down to the 4-5 position my signups are half what they are from 1-3. Move down the page and same thing, positions 6-7 are about half of what I get from positions 4-5. If I am only showing up on page 2 then I get nothing in signups. Right now, for Camfoxes I move between position 2 and 5 for Free Adult webcams quite a bit. When I am in position 2, things rock, when I am in position 4 I don't get shit. So, I put blame for any problems I have on google and cookie stuffing. . |
Quote:
I spent some time yesterday actually looking at cams which I did months ago, to get some ideas of what really goes on for sales text purposes, and really noticed a significant jump in links/watermarks to their OnlyFans. Wondering if members are finding it cheaper for them to buy a month pass at OF for their videos then purchasing a bunch of individual clips at CB. |
Quote:
But I could be wrong, I often am. . |
Quote:
I've noticed the jump in onlyfans links on CB and nothing is done to remove them. |
Quote:
|
Quote:
Makes Chaturbate appear very model friendly. just imho of course. . |
Quote:
I have not been very successful :( . |
The polite way for models to behave...
If you have not registered as a member of FCX or have never purchased points, please register from the URL below. https://is.gd/pW4xce |
Quote:
. |
Yeah.
Its a tough call for me. Webmasters like cam models have families. We all need to eat. But some of the cams girls are so oblivious or they are such assholes... Its not a good way to develop a career. of course on the other hand, don't get me started about webmasters. Thanks, Sarettah for your thoughtful posts. Its good to see here. |
All times are GMT -4. The time now is 04:20 AM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc