Jump to content

iainwood

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

iainwood's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for that, I'm trying to hack together something that works from the demo in the PHP files you can download from ZEND I took the google Docs File and basically murdered it to try and find out what works. (some guesswork was involved), This actually retrieves the site list- but I dont' know how?!?! Authenticaion is being done first, then it retrieves the feed. So step 1 getting a list of my sites from webmaster tools API with PHP is done, but pretty darn ugly, any takers on a simplified more elegant version of this? <?php require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_Loader::loadClass('Zend_Gdata_AuthSub'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); Zend_Loader::loadClass('Zend_Gdata_Docs'); session_start(); if (!isset($_SESSION['docsSampleSessionToken']) && !isset($_GET['token'])) { requestUserLogin('Please login to your Google Account.'); } else { $client = getAuthSubHttpClient(); $sites = new Zend_Gdata($client); retrieveAllSites($sites, true); } function printSitesFeed($feed, $html) { echo "Called - printSitesFeed <BR>"; if ($html) {echo "<ul>\n";} // Iterate over the document entries in the feed and display each document's // title. foreach ($feed->entries as $entry) { if ($html) { // Find the URL of the HTML view of the document. $alternateLink = ''; foreach ($entry->link as $link) { if ($link->getRel() === 'alternate') { $alternateLink = $link->getHref(); } } // Make the title link to the document on docs.google.com. echo "<li><a href=\"$alternateLink\">\n"; } echo "$entry->title\n"; if ($html) {echo "</a></li>\n";} } if ($html) {echo "</ul>\n";} } function retrieveAllSites($client, $html) { echo "Called - retrieveAllSites <BR>"; if ($html) {echo "<h2>Your documents</h2>\n";} $feed = $client -> getFeed('https://www.google.com/webmasters/tools/feeds/sites/'); //print_r($feed); // $feed = $client->getDocumentListFeed(); printSitesFeed($feed, $html); } function requestUserLogin($linkText) { echo "Called - requestUserLogin <BR>"; $authSubUrl = getAuthSubUrl(); echo "<a href=\"{$authSubUrl}\">{$linkText}</a>"; } function getAuthSubUrl() { echo "Called - getAuthSubUrl <BR>"; $next = getCurrentUrl(); $scope = 'https://www.google.com/webmasters/tools/feeds/sites/'; $secure = false; $session = true; return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure,$session); } function getAuthSubHttpClient() { echo "Called - getAuthSubHttpClient <BR>"; global $_SESSION, $_GET; if (!isset($_SESSION['docsSampleSessionToken']) && isset($_GET['token'])) { $_SESSION['docsSampleSessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']); } $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['docsSampleSessionToken']); print_r($client); return $client; } function getCurrentUrl() { echo "Called - getCurrentUrl <BR>"; global $_SERVER; /** * Filter php_self to avoid a security vulnerability. */ $php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0, strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES); if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { $protocol = 'https://'; } else { $protocol = 'http://'; } $host = $_SERVER['HTTP_HOST']; if ($_SERVER['SERVER_PORT'] != '' && (($protocol == 'http://' && $_SERVER['SERVER_PORT'] != '80') || ($protocol == 'https://' && $_SERVER['SERVER_PORT'] != '443'))) { $port = ':' . $_SERVER['SERVER_PORT']; } else { $port = ''; } return $protocol . $host . $port . $php_request_uri; }
  2. Hi Guys Has anyone had any experience using the webmaster tools API, I can't get my head around it. I have only used ZEND with pdf's before and not even that much then, it seems that they pitch ZEND as the way to do this, but I'm not able to find any relevant documentation (or am i missing something) I have googled this to death, so please only tell me to go to a link if it isn't easily found on google, what I'm after is a simple exampple of how to say get a list of the sites on my account, I think I can figure it out from there! Many thanks Iain
  3. Hi I found a solution at http://stackoverflow.com/questions/1299452/how-do-i-stop-a-page-from-unloading-navigating-away-in-js
  4. You would have to be looking at ajax here. It's pretty simple 1 call function 2 if they confirm call the ajaxfunction 3 when the ajax function is complete call the alert box again this should help ajaxget("delete.php?id=xxxx","resultsDiv","confirmdelete") function confirmdelete(){ alert("Delete Done"); } function ajaxget(url,outputid,funcToCall){ var AJAX; try { AJAX = new XMLHttpRequest(); } catch(e) { try { AJAX = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { AJAX = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX."); return false; } } } AJAX.onreadystatechange = function() { if(AJAX.readyState == 4) { if(AJAX.status == 200) { //execute the function eval(funcToCall + '()'); //write the resulting html to the div (or whatever) document.getElementById(outputid).innerHTML=AJAX.responseText; } else { alert("Error: "+ AJAX.statusText +" "+ AJAX.status); } } } AJAX.open("get", url, true); AJAX.send(null); }
  5. Hi onclick="showText(idoftextboxwithtextin, idofdivforcontenttogointo)" function showText(myid,mydiv){ document.getElementByID(mydiv).innerHTML=document.getElementByID(myid).value } this do it for you?
  6. Hi I have a backoffice system for my users, there is quite a complicated form in this that I need to make sure is saved on unload. My initial idea was to have a variable set by javascript on onchange and onkeydown functions on the elements - this works fine I can detect if they have potentially changed anything OnUnload I check this variable and ask them to confirm that they want to leave the changes, however if they click cancel the page still exits! so i tried making it offer to submit the form (see below) function confirmExit(){ alert(changeDetected) // just to show me the variable if (changeDetected!=0){ if(confirm("Do You Want to Save Changes")){ document.form1.submit() } } does anyone have a method for this? It must work in IE, ideally be cross browser! Thanks Iain
×
×
  • 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.