Jump to content

Recommended Posts

before i get burnt for asking, i have tried for days, watched videos, read stuff but its hard for an old fart to learn new tricks.

a brief outline of what i've done so far (without previous knowledge of wordpress or php)

 

1. created wordpress website - its going to be a subscription site for livedrive reseller

2. i have used plugins downloaded throught Wordpress and short codes in pages

 

in order to make the site automatic i need working php api's , Livedrive provide example api's but no support.

 

i have downloaded and installed wamp for testing.

 

i have made a folder in the plugin folder called api examples the files won't run if i try making a plugin file and activating but i have got them to work by copying the path into internet explorer like so;

 

http://localhost/wordpress/wp-content/plugins/apiexamples/closeuser.php which looks like screenshot 1 ld

 

this is one of several php files, which works in this page if i put in the api key and click submit.

 

I try copying the code and save it as a new php file and place it in  a new folder called test-livedrive inside the plugin folder.

 

my problems are;

 

i can't work out how to get a short code to work where i place the shortcode in a new page

 

if i paste the code as it shows into a page it shows all sorts of crap before the form at the bottom see screenshots 234

and if i put the my api key in the field box it fails.

 

so i'm failing miserably, i have even tried to find a freelancer on freelancer.co.uk but prices are about £500  i simply can't afford and seems an awful lot when a lot of coding is there, it just needs sorts.

 

appreciate and help/guidance/examples

 

thanks, duncpost-203058-0-20927400-1480766617_thumb.pngpost-203058-0-97200000-1480768084_thumb.pngpost-203058-0-57257800-1480768092_thumb.pngpost-203058-0-01674200-1480768101_thumb.png

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/302674-short-codes-and-php-files-in-wordpress/
Share on other sites

We'd need to see some actual code to see if there's an issue there. Having said that, you'll get shortcode working using the add_shortcode hook in your theme or plugin's functions file. It's also possible to use do_shortcode() in your template or functions file(s).

 

In addition, from a quick Google search it looks like there are a couple WP plugins already developed that may make your life a bit easier, especially if you don't know WP or PHP.

hi, many thanks for replying, i tried to show the code in the screen shots to give an idea but i am happy to attach files,also all files are available to download from here http://www.livedrive.com/api at base of page is the link to download them.

 

there is one plugin done for this for wordpress by cubettech but i have tried to contact them by there website and facebook with no response and it does not look like they have updated it for two years so relectuctant to try and buy it.

 

i would be more than happy to pay someone on here to assist but couldn't find anywhere on the site to request this

 

below is the code of one of the files if thats of help

 

again guidance appreciated

 

<html>
   <?php include('includes/Header.inc'); ?>
   <body>
      <div id="page">
         <div id="content">
             <?php include('includes/SideBar.inc'); ?>
              <div id="main_content">
<?php
if(isset($_POST['apiKey']))
{
   $totalUserArray = array();
   $currentPage = 1;
   do
   {
      $client = new SoapClient("https://www.livedrive.com/ResellersService/ResellerAPI.asmx?wsdl", array("trace"=> 1, "exceptions" => 0));
      $result = $client->GetUsers(array('apiKey' => $_POST['apiKey'], 'page' => $currentPage));
      $currentPage = $result->GetUsersResult->Page;
      $totalPages = $result->GetUsersResult->TotalPages;
      
      print "Page: " . $result->GetUsersResult->Page . "/". $result->GetUsersResult->TotalPages . "<br/>";
      $array = $result->GetUsersResult->Collection->LiveDriveUserManagement;
      if(count($array) == 1 ) {$array = array($array);}
      $totalUserArray = array_merge($totalUserArray, $array);
      $currentPage++;
   } while($currentPage <= $totalPages);

   print "<pre class='brush: php;' style='size: 7px'>";
   print "Request:\n".htmlspecialchars($client->__getLastRequest()) ."\n\n";
   print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
   print "</pre>";
   
   print "<table border='2' style='font-size: 9px; width: 1020px'>";
   print "<tr> <th>Row</th> <th>ID</th> <th>Email</th> <th>SubDomain</th> <th>Display Type</th> <th>Display Status</th> <th>Backup Space Used</th> <th>Backup Capacity</th> <th>Briefcase Space Used</th> <th>Briefcase Capacity</th> </tr>";
      
   foreach($totalUserArray as $k=>$v)
   {
      print "
      <tr>
         <td align='right'>" . ($k+1) . "</td>
         <td>" . $v->ID . "</td>
         <td>" . $v->Email . "</td>
         <td>" . $v->SubDomain . "</td>
         <td>" . $v->DisplayType . "</td>
         <td>" . $v->DisplayStatus . "</td>
         <td>" . $v->BackupSpaceUsed . "</td>
         <td>" . $v->BackupCapacity . "</td>
         <td>" . $v->BriefcaseSpaceUsed . "</td>
         <td>" . $v->BriefcaseCapacity . "</td>
      </tr>";
   }
  print "</table>";
}
else
{
?>
<h1>GetAllUsers Live Example:</h1>
<form id="getallusers" action="getallusers.php" method="post">
   What is your API KEY?
   <br/>
   <input id="apiKey" name="apiKey" size="50" type="text" value="" />
   <br/>
   <input id="submit" name="submit" type="submit" value="submit" />
</form>
      
<?php
}
?>
<br />
<h1>GetAllUsers() Code:</h1>
<pre class="brush: php;html-script: true" style="size: 8px">
<?php
if(isset($_POST['apiKey']))
{
   $totalUserArray = array();
   $currentPage = 1;
   do
   {
      $client = new SoapClient("https://www.livedrive.com/ResellersService/ResellerAPI.asmx?wsdl", array("trace"=> 1, "exceptions" => 0));
      $result = $client->GetUsers(array('apiKey' => $_POST['apiKey'], 'page' => $currentPage));
      $currentPage = $result->GetUsersResult->Page;
      $totalPages = $result->GetUsersResult->TotalPages;

      print "Page: " . $result->GetUsersResult->Page . "/". $result->GetUsersResult->TotalPages . "<br/>";
      $array = $result->GetUsersResult->Collection->LiveDriveUserManagement;
      if(count($array) == 1 ) {$array = array($array);}
      $totalUserArray = array_merge($totalUserArray, $array);
      $currentPage++;
   } while($currentPage <= $totalPages);

   print "<pre>";
   print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
   print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
   print "</pre>";
   
   print "<table border='2'>";
   print "<tr>" .
            "<th>Row</th>" .
            "<th>ID</th>" .
            "<th>Email</th>" .
            "<th>SubDomain</th>" .
            "<th>DisplayType</th>" .
            "<th>DisplayStatus</th>" .
            "<th>BackupSpaceUsed</th>" .
            "<th>BackupCapacity</th>" .
            "<th>BriefcaseSpaceUsed</th>" .
            "<th>BriefcaseCapacity</th>" .
         "</tr>";
      
   foreach($totalUserArray as $k=>$v)
   {
      print "<tr>" .
               "<td align='right'>" . ($k+1) . "</td>" .
               "<td>" . $v->ID . "</td>" .
               "<td>" . $v->Email . "</td>" .
               "<td>" . $v->SubDomain . "</td>" .
               "<td>" . $v->DisplayType . "</td>" .
               "<td>" . $v->DisplayStatus . "</td>" .
               "<td>" . $v->BackupSpaceUsed . "</td>" .
               "<td>" . $v->BackupCapacity . "</td>" .
               "<td>" . $v->BriefcaseSpaceUsed . "</td>" .
               "<td>" . $v->BriefcaseCapacity . "</td>" .
            "</tr>";
   }
  print "</table>";
}
else
{
?>
<br/>
<h1>GetAllUsers Live Example:</h1>
<form id="getallusers" action="getallusers.php" method="post">
   What is your API KEY?
   <br/>
   <input id="apiKey" name="apiKey" size="50" type="text" value="" />
   <br/>
   <input id="submit" name="submit" type="submit" value="submit" />
</form>
      
<?php
}
?>
</pre>
                </div>
         </div> <!-- #content -->
      </div> <!-- #page -->
   </body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.