0

Not getting deal id when the stage of deal is changed in Pipe drive with push notification api. I am getting the response

echo $result = file_get_contents('https://api.pipedrive.com /v1/pushNotifications?api_token=my-appid');

This is the code I have inserted when the http post is run

{"success":true,"data":  
    [{"id":7,"user_id":750195,"company_id":538560,"subscription_url":"https:\/\/empathi-solutions.com\/pipe\/pip.php",  
     "type":"regular","event":"updated.deal","http_auth_user":"","http_auth_password":"",   
     "add_time":"2015-08-03 07:41:04","active_flag":true,"remove_time":null,"http_last_response_code":200},  
     {"id":8,"user_id":750195,"company_id":538560,"subscription_url":"https:\/\/empathi-solutions.com\/pipe\/pip.php",  
     "type":"regular","event":"*.deal","http_auth_user":"","http_auth_password":"","add_time":"2015-08-03 08:47:56",  
     "active_flag":true,"remove_time":null,"http_last_response_code":200}],"additional_data":{"pagination":  
     {"start":0,"limit":100,"more_items_in_collection":false}}  
}

Please let me know How I can get the deal which stage has been changed?

Himanshu
  • 4,327
  • 16
  • 31
  • 39
vikram
  • 1
  • 2

1 Answers1

0

You can use json_decode function.

Try example

$result = file_get_contents('https://api.pipedrive.com/v1/pushNotifications?api_token=my-appid');

$result = json_decode($result, true);

foreach($result['data'] as $deal)
{
    echo "ID: ".$deal['id']."<br />";
    echo "User ID: ".$deal['user_id']."<br />";
    echo "Company ID: ".$deal['company_id']."<hr />";
}

UPDATE

$result = <<<JSON

{"success":true,"data":  
    [{"id":7,"user_id":750195,"company_id":538560,"subscription_url":"https:\/\/empathi-solutions.com\/pipe\/pip.php",  
     "type":"regular","event":"updated.deal","http_auth_user":"","http_auth_password":"",   
     "add_time":"2015-08-03 07:41:04","active_flag":true,"remove_time":null,"http_last_response_code":200},  
     {"id":8,"user_id":750195,"company_id":538560,"subscription_url":"https:\/\/empathi-solutions.com\/pipe\/pip.php",  
     "type":"regular","event":"*.deal","http_auth_user":"","http_auth_password":"","add_time":"2015-08-03 08:47:56",  
     "active_flag":true,"remove_time":null,"http_last_response_code":200}],"additional_data":{"pagination":  
     {"start":0,"limit":100,"more_items_in_collection":false}}  
}

JSON;



$result = json_decode($result, true);

foreach($result['data'] as $deal)
{
    echo "ID: ".$deal['id']."<br />";
    echo "User ID: ".$deal['user_id']."<br />";
    echo "Company ID: ".$deal['company_id']."<hr />";
}
Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
  • I appreciated your code. But i did not get the deal id in this. It is printing the notification id. I have checked the id in the https://developers.pipedrive.com/v1. I need the deal id which i did not get with your code. Please note in your above code $deal['id'] is not the id of the deal – vikram Aug 14 '15 at 09:00
  • @vikram I have updated my answer. There is no issue in my answer. Please provide me the `api_token` to test the live version. – Muhammad Hassaan Aug 15 '15 at 03:34