2014-10-16 105 views
0

已在API上使用此示例创建组。以PHP返回值的API

$response = $soap->createGroup(

array(

'api_key'=> $api_key, 
'group_name'=> 'Fred' 
) 

); 

这个效果很好。然而。我需要让API返回组ID。该API表示,以下

createGroup 
- Usage: Used to create a group that a recipient can be placed in. 
- Return: The id of the created group, used in such functions as addRecipient 
- Parameters 
o group_name (required), your reference to the group, e.g. ‘Group 1’ 
o add_recipients (optional), the id or an array of existing recipient ids to add to this group, see 
addRecipient 

我怎样才能做到这一点在PHP,这样我可以添加必要的收件人到这个组,尝试添加收件人需要以下时。

addRecipient 
- Usage: Used to add a recipient to your account 
- Return: The id of the added recipient 
- Parameters 
o email (required), the recipients email address 
o name (optional), the recipient's name 
o group (optional), id of an existing group, see createGroup. 

它需要组ID而不是名称。

非常感谢您的帮助,因为这一直困扰着我。

Louk

+0

是什么'$ response'是什么样子?组ID应该在那。 – 2014-10-16 21:52:49

+0

我试着回应它并得到这个'可捕捉的致命错误:类stdClass的对象无法转换为字符串/var/www/vhosts/icanpromo.co.uk/httpdocs/API/Add.php 31行' – 2014-10-16 21:59:15

+0

使用print_r($ response)代替 – 2014-10-16 22:00:26

回答

0

我假设你用Audiolock API工作。

获得从响应您createGroup查询组ID,然后使用该值在addRecipient查询:

# $response is the response from your createGroup query 
$addRecipResponse = $soap->AddRecipient(
    'email' => '[email protected]', 
    'group' => $response, 
    'api_key' => $api_key ## may be needed, may not be 
); 
# the response is the ID of the recipient 
$recip_id = $addRecipResponse($response->response); 
+0

啊顶级男人现在就试试吧! – 2014-10-16 22:04:23

+0

可悲的是,仍然无法正常工作....它会插入收件人,但不会将其添加到组中。 – 2014-10-16 22:08:36

+1

将'group'=> $ gid更改为'group'=> $ response,它工作正常!好一个!! – 2014-10-16 22:16:03