Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 962143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:27:29+00:00 2026-05-16T01:27:29+00:00

I use PHP to get a list of folders, and then documents from Google

  • 0

I use PHP to get a list of folders, and then documents from Google Docs (two API requests).

Getting a list of the folders, I can get their folderID, which is fine.

However, when getting a list of documents, it returns categories, and these only contain the name of the folder.

My problem exists because I have two folders with the same name, and my code is merging the documents from these, because they have the same name.

The function I use to get a list of the documents within the folder:

/**
 * Gets a list of 'internal' IDs of docs within a certain folder
 * @global Mixed $fileslist
 * @param String $folder
 * @return Array
 */
function getDocumentsInFolder($folder) {
    global $fileslist;

$docs = array();
foreach ($fileslist as $id => $files) {
    if (in_array($folder, $files['folders'])) {
        $docs[] = $id;
    }
}
return $docs;
}

And the arrays are:

    foreach ($list[$i]->category as $cat) {
        $folders[] = $cat->label;
    }
    $folderslist[$i] = array(
        'name' => $foldername,
        'authorname' => $authorname,
        'authoremail' => $authoremail,
        'lastupdated' => $lastupdated,
        'fid' => $fid
    );
    $fileslist[] = array(
        'name' => $name,
        'authorname' => $authorname,
        'authoremail' => $authoremail,
        'lastupdated' => $lastupdated,
        'folders' => $folders,
        'id' => $id,
        'type' => $list[$i]->extensionElements[0]->text,
    );

The XML the Google Docs API for the list of documents is @ http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#ListDocs (Note how the categories are just folder names).

Any ideas how to stop files appearing in all instances of that folder name, and just in their proper folder?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:27:30+00:00Added an answer on May 16, 2026 at 1:27 am

    Fixed it 🙂

    /**
     * Gets a list of 'internal' IDs of docs within a certain folder
     * @global Mixed $fileslist
     * @param ID $folder The internal ID of the folder
     * @return Array
     */
    function getDocumentsInFolder($folder) {
        global $fileslist, $folderslist;
        // Work out the folder ID
    
        $fid = $folderslist[$folder]['fid'];
        $docs = array();
        foreach ($fileslist as $id => $files) {
            if ($files['fid'] == $fid) {
                $docs[] = $id;
            }
        }
        return $docs;
    }
    

    The document list returns:

     <link rel="http://schemas.google.com/docs/2007#parent" type="application/atom+xml" href="https://docs.google.com/feeds/default/private/full/folder%3A12345" title="AFolderName"/>
    

    Which contains the folder ID, I was able to store this in the document list and then compare.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I use dns_get_record within a php script to get a list of DNS
I'm trying to use php to get the list of loaded apache modules using
I am retriveing data from a soap api using php. but unable to get
How can I sync local and remote folders using rsync from inside a php
I'm trying to use PHP's Glob to get a list of files based on
I wonder how can I get the list of MySQL databases in PHP using
I have a multiple language website, and I use a php get variable to
When I use call_user_func on a non-static method in PHP 5.2 I get a
I use php to display a table of data drawn from my mysql database.
I want to use PHP to replace javascript functions in HTML documents. For example:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.