2

i have an array:

 Array
(
[0] => BugHerd_Project Object
    (
        [id:BugHerd_Project:private] => 24323
        [name:BugHerd_Project:private] => bugherd a
        [devurl:BugHerd_Project:private] => http://st.com/a/
        [active:BugHerd_Project:private] => 1
        [created:BugHerd_Project:private] => DateTime Object
            (
                [date] => 2014-05-03 11:15:22
                [timezone_type] => 2
                [timezone] => Z
            )

        [updated:BugHerd_Project:private] => DateTime Object
            (
                [date] => 2014-05-05 06:55:52
                [timezone_type] => 2
                [timezone] => Z
            )

    )

)

1. my code of accessing this array is:

  • in this code im just fetching data from api .its simple http authentication code
  • im using php wrapper here is the link :https://github.com/spekkionu/bugherd.
  • from the api documentation they mention :curl -u api_key:x https://www.bugherd.com/api_v2/projects/1.json

     $api = new BugHerd_Api($email,$password);
    $projects = $api->listProjects();
    $i=0;
    on  doing print_r($projects[$i]['id:BugHerd_Project:private']);
    

    its result me error so how should i access this array.

0

1 Answer 1

3

You are trying to access id property of a class, the property is private so yo cannot access directly to it ($projects[$i]->id don't work)

According to the BugHerd_Project class there's a getter to access this property getId(), try $projects[$i]->getId()

Sign up to request clarification or add additional context in comments.

5 Comments

sr i found in bug Fatal error: Call to a member function getId() on a non-object give me some hint to resolve that issue.
Then you're trying to call the getId function on a non-object, post another question on SO, and post the code with the error
here is another error : Catchable fatal error: Object of class DateTime could not be converted to string i used to call :print_r($projects_particular->getCreated()); api function :public function getCreated() { return $this->created; }
here is the output i recived :DateTime Object ( [date] => 2014-05-05 10:04:30 [timezone_type] => 2 [timezone] => Z )
i have the same problem too how to get the date from datetime object

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.