WhatPulse Forums » Support » Client software v » Help me with the WebAPI Please Welcome back, Guest.


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help me with the WebAPI Please
04-08-2009, 02:24 PM
Post: #1
Help me with the WebAPI Please
Hey, as you can see I am having some problems displaying my stats:

http://getsomecashonline.com/whatpulse/about

The sidebar is where I want the stats to be displayed.

I only want it to show my Username, Total Keys, Clicks, Miles, and my world rank.

Could you please explain to me how to display this, as I am confused with how to use the files etc supplied on the webAPI on the main website.

Thanks a lot. Smile

http://www.suckmytrend.com

[Image: Slow2die.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2009, 02:35 PM
Post: #2
Help me with the WebAPI Please
Righo, just finished the facebook app so take a look at this. I decided against using the script that was available and wrote my own, although it's not brilliant it does the job Tongue

PHP Code:
<?php

    $userid 
$_GET['id'] ? $userid $_GET['id'] : exit("User ID can't be 0.");
    
$link file('http://whatpulse.org/api/user.php?UserID='$userid);
    
$x 0;
    
    
$output = array( array(345101112), array("User ID""Account Name""Country""Total Keys""Total Mouse Clicks""Total Miles"));
    !empty(
$link[$output[0][0]]) ? '' : exit("Invalid user ID. Please check and try again.");
    
    while (
$x count($output[0])) 
    {
        
$line strip_tags($link[$output[0][$x]]);
        
$x == $line " <img src=\"images/".str_replace(" """$line).".png\">" $line : ($x == || $x == $line number_format($line) : ($x == $line number_format($line3) : '')) ;
        echo 
"<b>".$output[1][$x]."</b>: ".$line."<br>";
        
$x++;
    }
    
?>

Just change $userid to match your whatpulse user ID and it will display your User ID, Account name, total keys, clicks and miles as well as your country (not in that order).

Did you know that eating cheese can give you cancer?

If anyone cares, my Avatar has a name. It is Bob. Bob the fluffy thing.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2009, 02:55 PM (This post was last modified: 04-08-2009 03:05 PM by Xtr3me.)
Post: #3
Help me with the WebAPI Please
Cheers dude, should I leave the $ before the user ID?


EDIT:

Quote: $userid = $_GET['id'] ? $userid = $_GET['id'] : exit("User ID can't be 0.");
$link = file('http://whatpulse.org/api/user.php?UserID='. 247255);


That just displays:
User ID can't be 0

Remove the full stop? I really should of studied my 700 page PHP book. Tongue

http://www.suckmytrend.com

[Image: Slow2die.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2009, 03:12 PM
Post: #4
Help me with the WebAPI Please
Change it to:

PHP Code:
$userid 247255// 247255 is your specific user id 

The code i gave you was to be used to get any record so you could actually remove the $userid; line and change the $link; line to read:

PHP Code:
$link file('http://whatpulse.org/api/user.php?UserID='247255); 

Did you know that eating cheese can give you cancer?

If anyone cares, my Avatar has a name. It is Bob. Bob the fluffy thing.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2009, 03:16 PM
Post: #5
Help me with the WebAPI Please
kk, gotta wait for my site to update now, for some really fucking strange reason the sidebar doesnt update for ages. =/

http://www.suckmytrend.com

[Image: Slow2die.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2009, 03:39 PM
Post: #6
Help me with the WebAPI Please
K its updated.

Invalid user ID. Please check and try again.

Not sure what I did wrong:

Quote:<center>
<?php

$userid = 247255; // 247255 is your specific user id
$x = 0;

$output = array( array(3, 4, 5, 10, 11, 12), array("User ID", "Account Name", "Country", "Total Keys", "Total Mouse Clicks", "Total Miles"));
!empty($link[$output[0][0]]) ? '' : exit("Invalid user ID. Please check and try again.");

Thats the code I got going.

http://www.suckmytrend.com

[Image: Slow2die.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2009, 03:51 PM
Post: #7
Help me with the WebAPI Please
PHP Code:
<?php

    $link 
file('http://whatpulse.org/api/user.php?UserID=247255');
    
$x 0;
    
    
$output = array( array(345101112), array("User ID""Account Name""Country""Total Keys""Total Mouse Clicks""Total Miles"));
    !empty(
$link[$output[0][0]]) ? '' : exit("Invalid user ID. Please check and try again.");
    
    while (
$x count($output[0])) 
    {
        
$line strip_tags($link[$output[0][$x]]);
        
$x == $line " <img src=\"images/".str_replace(" """$line).".png\">" $line : ($x == || $x == $line number_format($line) : ($x == $line number_format($line3) : '')) ;
        echo 
"<b>".$output[1][$x]."</b>: ".$line."<br>";
        
$x++;
    }
    
?>

Should work

Did you know that eating cheese can give you cancer?

If anyone cares, my Avatar has a name. It is Bob. Bob the fluffy thing.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2009, 04:06 PM
Post: #8
Help me with the WebAPI Please
Works perfectly. Only thing not displaying is the GB flag image, but its all good. Thanks a lot dude. Look forward to seeing the facebook App Big Grin

Heres the sidebar in action:

http://getsomecashonline.com/whatpulse/

http://www.suckmytrend.com

[Image: Slow2die.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2009, 04:17 PM
Post: #9
Help me with the WebAPI Please
OOh images won't work properly unless either A: You upload them all to your website or B: You just link them to the directory where they are saved on my website (Which is a hell of a lot easier xD)

So change the following line:
PHP Code:
$x == $line " <img src=\"images/".str_replace(" """$line).".png\">" $line : ($x == || $x == $line number_format($line) : ($x == $line number_format($line3) : '')) ; 

To read:
PHP Code:
$x == $line " <img src=\"http://phpbox.co.uk/apps/Whatpulse/Images//".str_replace(" """$line).".png\">" $line : ($x == || $x == $line number_format($line) : ($x == $line number_format($line3) : '')) ; 

And it should work perfectly.

I'm gonna rewrite the code as well to make it specific to you, since it's a bit bloated for just one user.

Did you know that eating cheese can give you cancer?

If anyone cares, my Avatar has a name. It is Bob. Bob the fluffy thing.
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2009, 04:29 PM
Post: #10
Help me with the WebAPI Please
You dont have to go rewriting it all dude, its perfect. Just gonna change this image here quick Big Grin

http://www.suckmytrend.com

[Image: Slow2die.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)