Retrieve Coffer

This is used for general discussion that is not necessarily server-related.
Post Reply
FlyingMongoose
This is my homepage
This is my homepage
Posts: 353
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Fri Sep 17, 2004 7:50 pm
Contact:

Retrieve Coffer

Post by FlyingMongoose »

So I'm attempting to build a wordpress plugin that handles donations, and while I could work with the paypal API myself, I'd rather my potential donators know that they are donating straight to the server, so I intend to essentially have this plugin link directly to the nfo donate.pl system.

Now, obviously within my own control panel I can view the coffer, but is there a way I could have my wordpress plugin retrieve the current coffer? (Is there an externally accessible API that allows me to do this?)

I essentially want to display a [current coffer] out of [total cost] on my page and use the NFO systems for donation.
Image
User avatar
Vanderburg
Former staff
Former staff
Posts: 1253
Joined: Sat Nov 13, 2010 7:27 am
Location: Dallas, TX

Re: Retrieve Coffer

Post by Vanderburg »

This is something that has been suggested in the past, but there's no current API for this. Currently, the only way you'd be able to get this is to have a plugin or script pass the HTTP auth for the control panel and pull that information off the Payments tab.
FlyingMongoose
This is my homepage
This is my homepage
Posts: 353
Joined: Fri Sep 17, 2004 7:50 pm
Contact:

Re: Retrieve Coffer

Post by FlyingMongoose »

That is a really really inefficient way to do things... but I guess I can do it that way.
Image
FlyingMongoose
This is my homepage
This is my homepage
Posts: 353
Joined: Fri Sep 17, 2004 7:50 pm
Contact:

Re: Retrieve Coffer

Post by FlyingMongoose »

For anyone who wishes future reference, here is what I ended up coming up with (took a long time)

Code: Select all

<?php
//Get NFO Data

$username = "EMAIL";
$password = "PASSWORD";
$geturl = "https://www.nfoservers.com/control/account_payments.pl";

$refurl = "https://www.nfoservers.com/control/account_payments.pl";

$params = "email=" . $username . "&" . "password=" . $password;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $geturl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HEADER, true); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $params); 
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefile"); 
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookiefile"); # SAME cookiefile 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_REFERER, $ref_url);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, true);
//curl_setopt($ch, CURLOPT_POST, true);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);

$nfod_currentcoffer = nfod_get_string_between($output, "<b style='font-size:16pt'>","</b>");
	
function nfod_get_string_between($string, $start, $end){
	$string = " ".$string;
	$ini = strpos($string,$start);
	if ($ini == 0) return "";
		$ini += strlen($start);
	$len = strpos($string,$end,$ini) - $ini;
	return substr($string,$ini,$len);
}

$nfod_currentcoffer will have the value of your current coffer stored. You could always turn this into a function, but I only needed it stored in a variable myself.

I bet there's a little redundancy in the auth methods there too, but I can't be certain.
Image
FlyingMongoose
This is my homepage
This is my homepage
Posts: 353
Joined: Fri Sep 17, 2004 7:50 pm
Contact:

Re: Retrieve Coffer

Post by FlyingMongoose »

Making use of this feature inside a wordpress plugin I put together:

(If linking is allowed)
http://brbu.site.nfoservers.com/wordpress/

I've even worked in a width setting to the display's background that is based on essentially what would be a graphical representation of the percentage of total cost covered by the coffer.
Image
User avatar
Edge100x
Founder
Founder
Posts: 12947
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Retrieve Coffer

Post by Edge100x »

We don't officially support automated tools using the control panel, and the Payments page is a particularly intensive one for us to create server-side. If you plan to pull data from it, you need to make sure that you're only doing it rarely (such as once a day) and properly caching the result.
FlyingMongoose
This is my homepage
This is my homepage
Posts: 353
Joined: Fri Sep 17, 2004 7:50 pm
Contact:

Re: Retrieve Coffer

Post by FlyingMongoose »

Alright, I'll make it handle that way through a cron job. Still it'd be nice to have an API with access.
Image
xancara
New to forums
New to forums
Posts: 9
Joined: Mon Aug 13, 2012 8:10 pm

Re: Retrieve Coffer

Post by xancara »

Sorry to necro this old thread but didn't see a point in making another thread about it.

Would it be possible for NFO to just supply a once a day updated PNG generating php/perl/python script(or any other image) with the current coffer total? Possibly make it a feature of the web hosting, VDS rental, dedicated rental or something of the sort?

Since this would be somewhat additionally taxing on the NFO servers if everyone were to poll for this data on each page load, I don't want to use the curl method that was provided in this thread but I would like some way to put this data out.

I am switching from doing server donations through a paypal goal widget to going directly through NFO for the donations to make things easier on my community and myself.

Has there been any better effort put towards this or is it pretty much still sitting at the point that it was left at here? I haven't been able to find too many other relevant threads with actual information in them.

Thanks in advance Edge and Co.
Post Reply