PDA

View Full Version : Building a plugin need help


demo7up
09-06-2012, 11:22 AM
I would like to build a plugin based on the following code


$json = file_get_contents("http://us.battle.net/api/wow/character/Shattered%20Hand/". $vbulletin->userinfo['username']."?fields=guild,items,professions,reputation,stats", true);
$decode = json_decode($json, true);
$name = " ". $decode[name] ."";
$realm = " ". $decode[realm] ."";
$ailevel = " ". $decode[items][averageItemLevel] ."";
$aeilevel = " ". $decode[items][averageItemLevelEquipped] ."";
$helm = " ". $decode[items][head][name] ."";
$Thumbnail = "". $decode[thumbnail] ."";
$guild_name = " ". $decode[guild][name] ."";

echo "<img src=\"http://us.battle.net/static-render/us/".$Thumbnail."\">";


It loads sucessfully but all the way at the top of the forum and pushes the board down.

doesnt matter where i add {vb:raw wowapi}

nhawk
09-06-2012, 11:32 AM
Not knowing where you want it to appear makes it hard to help.

But the echo is what's doing it.

Change the echo to a template hook where you want it to appear.

ie:
$template_hook['postbit_userinfo_right'] .= "<img src=\"http://us.battle.net/static-render/us/".$Thumbnail."\">";

demo7up
09-06-2012, 12:06 PM
How would i make this show under or above toplinks?

Thanks for your quick response

--------------- Added 1346937602 at 1346937602 ---------------

I think i figured it out i just have one problem....

$json = file_get_contents("http://us.battle.net/api/wow/character/Shattered%20Hand/". $vbulletin->userinfo['username']."?fields=guild,items,professions,reputation,stats", true);
the code above requires members to sign up with their character name..

how can i tell the script to die if the link fails to load?

--------------- Added 1346961011 at 1346961011 ---------------

Okay my plugin is working awesome with your guidance justt need help with on piece of code... please :)

what do i need to add to my code to not display the plugin if user is not logged in?

nhawk
09-07-2012, 12:09 PM
Something like this would work...

if ($vbulletin->userinfo['userid'])
{
//Your Code Here
}