1

When using php library for RTM (https://github.com/bartosz-maciaszek/php-rtm), I am getting a response for a particular tasks-list like this:

Rtm\DataContainer Object
(
    [attributes:Rtm\DataContainer:private] => Array
        (
            [0] => Rtm\DataContainer Object
                (
                    [attributes:Rtm\DataContainer:private] => Array
                        (
                            [id] => 19594773
                            [taskseries] => Rtm\DataContainer Object
                                (
                                    [attributes:Rtm\DataContainer:private] => Array
                                        (
                                            [id] => 310899576
                                            [created] => 2013-10-03T05:35:52Z
                                            [modified] => 2013-11-06T17:24:36Z
                                            [name] => A new task
                                            [source] => js
                                            [url] => 
                                            [location_id] =>

                                        )
                                )
                        )
              )
      )
)

I want to get the value of [name]. How can I do it?

1 Answer 1

1

As far as I could understand from the docs, you have to call something like

$receivedObject->getTaskSeries()->getName()

Or there is a suggestion to apply toArray or toJson to returned object - that should work.

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

2 Comments

Thanks for the answer but getName() gives fatal error: Call to a member function getName() on a non-object. toArray is probably right way to do it.
Ok. Got it fixed..traversing it using foreach did the trick for me. However for real response object I have to use foreach twice: foreach ($response as $item) { $ts = $item->getTaskseries(); foreach ($ts as $item2) { $name[] = $item2->getName(); } } print_r($name[0]);

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.