get 'url' key value from links collection entry
Closed this issue · 3 comments
I'm trying to get the 'url' value from a link entry object. I typically work with javascript and json so I expected to be able to do something in php like,
$link_entry->url
that format gives me what I want for keys like, $link_entry->total_unique_clicks
but for url I get the 'self_link' value (without the aweber root).
For instance if I echo a link entry formatted as I would expect a json object. I get something that looks like,
{
"total_unique_clicks":1, "clicks_collection_link":"https:\/\/api.aweber.com\/1.0\/accounts\/530794\/lists\/1738491\/campaigns\/b12999136\/links\/311\/clicks",
"url":"http:\/\/www.amiraalvarez.com",
"self_link":"https:\/\/api.aweber.com\/1.0\/accounts\/530794\/lists\/1738491\/campaigns\/b12999136\/links\/311",
"resource_type_link":"https:\/\/api.aweber.com\/1.0\/#link",
}
if I echo $link_entry->url I get,
/accounts/530794/lists/1738491/campaigns/b12999136/links/311
This is probably me not knowing some php magic. How would I get the value of the 'url' key?
I worked around this issue by copying the object to an array
function objToArray($r) { $a = array(); foreach($r as $k => $v) { $a[$k] = $v; } return $a; }
Then I can access the value using $le['url'].
Please do not write below this line, to reply write above
[AWeber] Re: [AWeber-API-PHP-Library] get 'url' key value from links collection entry (#13) (ticket #102989)
Jack,
Your request (#102989) has been updated.
To review, comment or reopen the request, simple reply to this email.
AWeber - Steve Elsner, Feb 17 04:59 pm (EST):
Hi Jack,
This does work counter-intuitively. It's a limitation of our PHP Client Library at present, but there is a workaround:
$this_is_an_array = $link_entry->attrs();
echo $this_is_an_array["url"]."\n";
Our dev team is aware of this issue, though there is no ETA on a fix. It will not likely be until the next major Client Library version, so I recommend sticking with the workaround above.
Incidentally, attrs() is a function on our aweber_entity objects that simply returns an array of all of the object's attributes, so you can iterate through it, or to a print_r() to examine its contents.
Please let me know if you have any further questions.
Hope this helps,
Steve Elsner
Web Operations Specialist
Jack Alves, Feb 10 08:55 pm (EST):
I'm trying to get the 'url' value from a link entry object. I typically work with javascript and json so I expected to be able to do something in php like,
$link_entry->url
that format gives me what I want for keys like, $link_entry->total_unique_clicks
but for url I get the 'self_link' value (without the aweber root).
For instance if I echo a link entry formatted as I would expect a json object. I get something that looks like,
{
"total_unique_clicks":1, "clicks_collection_link":"https:\/\/api.aweber.com\/1.0\/accounts\/530794\/lists\/1738491\/campaigns\/b12999136\/links\/311\/clicks",
"url":"http:\/\/www.amiraalvarez.com",
"self_link":"https:\/\/api.aweber.com\/1.0\/accounts\/530794\/lists\/1738491\/campaigns\/b12999136\/links\/311",
"resource_type_link":"https:\/\/api.aweber.com\/1.0\/#link",
}
if I echo $link_entry->url I get,
/accounts/530794/lists/1738491/campaigns/b12999136/links/311
This is probably me not knowing some php magic. How would I get the value of the 'url' key?
Reply to this email directly or view it on GitHub:
#13
This email is a service from AWeber Communications
Just doing some housekeeping.