Jump to content

sublevel4

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by sublevel4

  1. I don't think i stated my original issue correctly.

     

    output of $resmilestone gives me something like:

     

    [body] => SimpleXMLElement Object
            (
                [@attributes] => Array
                    (
                        [type] => array
                    )
    
                [milestone] => Array
                    (
                        [0] => SimpleXMLElement Object
                            (
                                [all-day] => true
                                [commented-at] => SimpleXMLElement Object
                                    (
                                        [@attributes] => Array
                                            (
                                                [nil] => true
                                            )
    
                                    )
    
                                [comments-count] => 0
                                [completed] => false
                                [created-on] => 2012-07-27T14:53:29Z
                                [creator-id] => 9459713
                                [id] => 33086455
                                [project-id] => 9115676
                                [responsible-party-id] => 4538224
                                [responsible-party-type] => Person
                                [start-at] => SimpleXMLElement Object
                                    (
                                        [@attributes] => Array
                                            (
                                                [nil] => true
                                            )
    
                                    )
    
                                [title] => Creative
                                [wants-notification] => true
                                [type] => Milestone
                                [creator-name] => Lynn
                                [deadline] => 2012-09-06
                                [responsible-party-name] => Michelle
                            )
    
                        [1] => SimpleXMLElement Object
                            (
                                [all-day] => true
                                [commented-at] => SimpleXMLElement Object
                                    (
                                        [@attributes] => Array
                                            (
                                                [nil] => true
                                            )
    
                                    )
    
                                [comments-count] => 0
                                [completed] => false
                                [created-on] => 2012-07-27T14:53:46Z
                                [creator-id] => 9459713
                                [id] => 33086460
                                [project-id] => 9115676
                                [responsible-party-id] => 9459713
                                [responsible-party-type] => Person
                                [start-at] => SimpleXMLElement Object
                                    (
                                        [@attributes] => Array
                                            (
                                                [nil] => true
                                            )
    
                                    )
    
                                [title] => Approval
                                [wants-notification] => true
                                [type] => Milestone
                                [creator-name] => Lynn
                                [deadline] => 2012-09-13
                                [responsible-party-name] => Lynn
                            )
    
                    )
    
            )
    
        [status] => 200 OK
        [location] => 
    )
    

     

    I am getting the info in the

    [1]

    and i need the one in the

    [0]

    I hope this sheads a little bit more light on what i am trying to get.

     

    Thanks.

  2. Here is the code

     

    foreach($response['body']->project as $project){	  
    
    // output only where status is active
    if ($project->status == 'active'){		
    	$created = $project->{'created-on'};		
    	$catagory = $project->company->name;
    	$project_name = $project->name;
    	$projectId = $project->id;
    
    	$resmilestones = $bc->getMilestonesForProject($projectId,$filter_type='late',$format=null);
    
    	foreach($resmilestones['body']->milestone as $milestone){
    	$late_date = $milestone->deadline;
    	$responsible = $milestone->{'responsible-party-name'};
    	$milestone_name = $milestone->title;
    
    	$milestone_data = $late_date . ' , ' . $responsible . ' , ' . $milestone_name . "\n";
    
    
    
    	}
    
    
    
    
    	$data_string .= $projectId .',' . $created .',' . $catagory .',' . $project_name .',' . $late_date . ' , ' . $responsible . ' , ' . $milestone_name . "\n";
    }
    
    
    }

     

    in the part

    foreach($resmilestones['body']->milestone as $milestone)

    i only want to get the first element. i don't need the others some items have none and some have 10 but i just need the first one as it is the Milestone that is the most over due the last one that i am getting now is the least overdue. And i apparently have no clue how to go about this.

  3. I have the following code

    foreach($response['body']->project as $project){	  
    
    // output only where status is active
    if ($project->status == 'active'){		
    	$created = $project->{'created-on'}.',';		
    	$catagory = $project->company->name.',';
    	$project = $project->name;
    	$projectNumber = $project->id . '<br>';
    
    	echo $projectNumber;
    
    	$data_string .= $created . $catagory . $project. "\n";
    }
    
    
    }

     

    if i print the array i get

    [body] => SimpleXMLElement Object
            (
                [@attributes] => Array
                    (
                        [type] => array
                    )
    
                [project] => Array
                    (
                        [0] => SimpleXMLElement Object
                            (
                                [created-on] => 2009-11-30
                                [id] => 4038672
                                [last-changed-on] => 2009-12-21T21:02:37Z
                                [name] => Reusable bags
                                [status] => archived
                                [company] => SimpleXMLElement Object
                                    (
                                        [id] => 1621970
                                        [name] =>  Marketing
                                    )
    
                            )

     

    $project comes back as Reusable bags

    $created comes back as 2009-11-30

    $catagory comes back as marketing

     

    My problem is that $projectNumber comes back blank.

    Is there something wrong with my code  that would cause this? How can i access all of other items but that one.

    Any help is appreciated. Thank you!

  4. if i put

     

    <?php
    require('includes/Basecamp.class.php');
    
    $n=0;
    
    $bc = new Basecamp('https://bsasgm.basecamphq.com','USERName','password','simplexml');
    $response = $bc->getProjects();
    
        // iterate the projects
        foreach($response['body']->project as $project){	  
    
    	echo $n. '<br/>';
    	$n++;		
    
    
    }
    
    
    
    
    
    ?>

     

    I get a list of 0 through 2498

     

    if i put in just

    print_r($response['body']->project);

     

    it returns

    SimpleXMLElement Object
    (
        [created-on] => 2009-11-30
        [id] => 4038672
        [last-changed-on] => 2009-12-21T21:02:37Z
        [name] => Reusable bags
        [status] => archived
        [company] => SimpleXMLElement Object
            (
                [id] => 1621970
                [name] => Marketing
            )
    
    )

     

     

    What i am trying to do is list each project as: Date created, ID, name, Status

  5. this code worked before a server move and now i get errors

     

    <?php
    
    require('includes/Basecamp.class.php');
    
    $n=0;
    
    $bc = new Basecamp('https://sub.basecamphq.com','name','password','simplexml');
    $response = $bc->getProjects();
    
    echo $response;
    
    echo 'date created,Company name,Project name';
    
        // iterate the projects
        foreach($response['body']->project as $project){	  
    
    	// output only where status is active
    	if ($project[$n]->status == 'active'){		
    		$created = $project[$n]->{'created-on'}.',';		
    		$catagory = $project[$n]->company->name.',';
    		$project = $project[$n]->name;
    		//echo '<br>__________________________________<br>';
    		$n++;
    		$data_string .= $created . $catagory . $project."\n";
    	}
    
    
    
    }
    
    echo $data_string;
    
    $filename = 'active_jobs.txt';
    
    file_put_contents($filename, $data_string); 
    
    header('Content-disposition: attachment; filename='.$filename.'');
    header('Content-type: text/plain');
    
    
    ?>

     

    now i get

     

    Warning: main() [function.main]: Cannot add element project number 1 when only 0 such elements exist in /home/...  .../basecamp/project_list_active.php on line 18

     

     

    I am not sure what is going on here. Any help would be appreciated.

     

    Thanks!

  6. I have the following code

    $response = $bc->getProjects();
        // iterate the projects
        foreach($response['body']->project as $project){
          print_r($project[$n]->name);
      print_r($project[$n]->company->name);
      echo '<br>__________________________________<br>';
      $n++;
    }

     

    That gives me this output

    SimpleXMLElement Object
    (
        [0] => Dancing 
    )
    SimpleXMLElement Object
    (
        [0] => Marketing
    )
    <br>__________________________________<br>

     

    How do i get rid of the SimpleXMLElement Object in the output?

     

×
×
  • 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.