infobip delivery reports and logs












0















I'm using Infobip SMS API to send SMSs to single and muliple destinations, but the delivery reports and SMS logs I get are overwhelming to my users, I want to display just part of the report for each SMS sent. Here is a sample of a JSON report my users get, I just need the groupName parts of the report



    {
"results":[
{
"bulkId":"bafdeb3d-719b-4cce-8762-54d47b40f3c5",
"messageId":"07e03aae-fabc-44ad-b1ce-222e14094d70",
"to":"41793026727",
"from":"InfoSMS",
"text":"Test SMS.",
"sentAt":"2015-02-23T17:41:11.833+0100",
"doneAt":"2015-02-23T17:41:11.843+0100",
"smsCount":1,
"mccmnc":"22801",
"price":{
"pricePerMessage":0.01,
"currency":"EUR"
},
"status":{
"groupId":3,
"groupName":"DELIVERED",
"id":5,
"name":"DELIVERED_TO_HANDSET",
"description":"Message delivered to handset"
},
"error":{
"groupId":0,
"groupName":"OK",
"id":0,
"name":"NO_ERROR",
"description":"No Error",
"permanent":false
}
},
{
"bulkId":"06479ba3-5977-47f6-9346-fee0369bc76b",
"messageId":"1f21d8d7-f306-4f53-9f6e-eddfce9849ea",
"to":"41793026727",
"from":"InfoSMS",
"text":"Test SMS.",
"sentAt":"2015-02-23T17:40:31.773+0100",
"doneAt":"2015-02-23T17:40:31.787+0100",
"smsCount":1,
"mccmnc":"22801",
"price":{
"pricePerMessage":0.01,
"currency":"EUR"
},
"status":{
"groupId":3,
"groupName":"DELIVERED",
"id":5,
"name":"DELIVERED_TO_HANDSET",
"description":"Message delivered to handset"
},
"error":{
"groupId":0,
"groupName":"OK",
"id":0,
"name":"NO_ERROR",
"description":"No Error",
"permanent":false
}
}
]
}









share|improve this question























  • Possible duplicate of php: loop through json array

    – Mohammad
    Nov 21 '18 at 10:38











  • I tried the answers from that with a foreach loop but I get an error Object of class stdClass could not be converted to string when execution reaches the value price, I think because it is another array

    – Eddy Khalfan
    Nov 21 '18 at 11:53













  • You need to put true in second parameter. $arr = json_decode($json, true) that cause convert json string to array. Then loop through $arr['results']

    – Mohammad
    Nov 21 '18 at 11:57













  • Thank you, that worked

    – Eddy Khalfan
    Nov 21 '18 at 12:25
















0















I'm using Infobip SMS API to send SMSs to single and muliple destinations, but the delivery reports and SMS logs I get are overwhelming to my users, I want to display just part of the report for each SMS sent. Here is a sample of a JSON report my users get, I just need the groupName parts of the report



    {
"results":[
{
"bulkId":"bafdeb3d-719b-4cce-8762-54d47b40f3c5",
"messageId":"07e03aae-fabc-44ad-b1ce-222e14094d70",
"to":"41793026727",
"from":"InfoSMS",
"text":"Test SMS.",
"sentAt":"2015-02-23T17:41:11.833+0100",
"doneAt":"2015-02-23T17:41:11.843+0100",
"smsCount":1,
"mccmnc":"22801",
"price":{
"pricePerMessage":0.01,
"currency":"EUR"
},
"status":{
"groupId":3,
"groupName":"DELIVERED",
"id":5,
"name":"DELIVERED_TO_HANDSET",
"description":"Message delivered to handset"
},
"error":{
"groupId":0,
"groupName":"OK",
"id":0,
"name":"NO_ERROR",
"description":"No Error",
"permanent":false
}
},
{
"bulkId":"06479ba3-5977-47f6-9346-fee0369bc76b",
"messageId":"1f21d8d7-f306-4f53-9f6e-eddfce9849ea",
"to":"41793026727",
"from":"InfoSMS",
"text":"Test SMS.",
"sentAt":"2015-02-23T17:40:31.773+0100",
"doneAt":"2015-02-23T17:40:31.787+0100",
"smsCount":1,
"mccmnc":"22801",
"price":{
"pricePerMessage":0.01,
"currency":"EUR"
},
"status":{
"groupId":3,
"groupName":"DELIVERED",
"id":5,
"name":"DELIVERED_TO_HANDSET",
"description":"Message delivered to handset"
},
"error":{
"groupId":0,
"groupName":"OK",
"id":0,
"name":"NO_ERROR",
"description":"No Error",
"permanent":false
}
}
]
}









share|improve this question























  • Possible duplicate of php: loop through json array

    – Mohammad
    Nov 21 '18 at 10:38











  • I tried the answers from that with a foreach loop but I get an error Object of class stdClass could not be converted to string when execution reaches the value price, I think because it is another array

    – Eddy Khalfan
    Nov 21 '18 at 11:53













  • You need to put true in second parameter. $arr = json_decode($json, true) that cause convert json string to array. Then loop through $arr['results']

    – Mohammad
    Nov 21 '18 at 11:57













  • Thank you, that worked

    – Eddy Khalfan
    Nov 21 '18 at 12:25














0












0








0


1






I'm using Infobip SMS API to send SMSs to single and muliple destinations, but the delivery reports and SMS logs I get are overwhelming to my users, I want to display just part of the report for each SMS sent. Here is a sample of a JSON report my users get, I just need the groupName parts of the report



    {
"results":[
{
"bulkId":"bafdeb3d-719b-4cce-8762-54d47b40f3c5",
"messageId":"07e03aae-fabc-44ad-b1ce-222e14094d70",
"to":"41793026727",
"from":"InfoSMS",
"text":"Test SMS.",
"sentAt":"2015-02-23T17:41:11.833+0100",
"doneAt":"2015-02-23T17:41:11.843+0100",
"smsCount":1,
"mccmnc":"22801",
"price":{
"pricePerMessage":0.01,
"currency":"EUR"
},
"status":{
"groupId":3,
"groupName":"DELIVERED",
"id":5,
"name":"DELIVERED_TO_HANDSET",
"description":"Message delivered to handset"
},
"error":{
"groupId":0,
"groupName":"OK",
"id":0,
"name":"NO_ERROR",
"description":"No Error",
"permanent":false
}
},
{
"bulkId":"06479ba3-5977-47f6-9346-fee0369bc76b",
"messageId":"1f21d8d7-f306-4f53-9f6e-eddfce9849ea",
"to":"41793026727",
"from":"InfoSMS",
"text":"Test SMS.",
"sentAt":"2015-02-23T17:40:31.773+0100",
"doneAt":"2015-02-23T17:40:31.787+0100",
"smsCount":1,
"mccmnc":"22801",
"price":{
"pricePerMessage":0.01,
"currency":"EUR"
},
"status":{
"groupId":3,
"groupName":"DELIVERED",
"id":5,
"name":"DELIVERED_TO_HANDSET",
"description":"Message delivered to handset"
},
"error":{
"groupId":0,
"groupName":"OK",
"id":0,
"name":"NO_ERROR",
"description":"No Error",
"permanent":false
}
}
]
}









share|improve this question














I'm using Infobip SMS API to send SMSs to single and muliple destinations, but the delivery reports and SMS logs I get are overwhelming to my users, I want to display just part of the report for each SMS sent. Here is a sample of a JSON report my users get, I just need the groupName parts of the report



    {
"results":[
{
"bulkId":"bafdeb3d-719b-4cce-8762-54d47b40f3c5",
"messageId":"07e03aae-fabc-44ad-b1ce-222e14094d70",
"to":"41793026727",
"from":"InfoSMS",
"text":"Test SMS.",
"sentAt":"2015-02-23T17:41:11.833+0100",
"doneAt":"2015-02-23T17:41:11.843+0100",
"smsCount":1,
"mccmnc":"22801",
"price":{
"pricePerMessage":0.01,
"currency":"EUR"
},
"status":{
"groupId":3,
"groupName":"DELIVERED",
"id":5,
"name":"DELIVERED_TO_HANDSET",
"description":"Message delivered to handset"
},
"error":{
"groupId":0,
"groupName":"OK",
"id":0,
"name":"NO_ERROR",
"description":"No Error",
"permanent":false
}
},
{
"bulkId":"06479ba3-5977-47f6-9346-fee0369bc76b",
"messageId":"1f21d8d7-f306-4f53-9f6e-eddfce9849ea",
"to":"41793026727",
"from":"InfoSMS",
"text":"Test SMS.",
"sentAt":"2015-02-23T17:40:31.773+0100",
"doneAt":"2015-02-23T17:40:31.787+0100",
"smsCount":1,
"mccmnc":"22801",
"price":{
"pricePerMessage":0.01,
"currency":"EUR"
},
"status":{
"groupId":3,
"groupName":"DELIVERED",
"id":5,
"name":"DELIVERED_TO_HANDSET",
"description":"Message delivered to handset"
},
"error":{
"groupId":0,
"groupName":"OK",
"id":0,
"name":"NO_ERROR",
"description":"No Error",
"permanent":false
}
}
]
}






php json






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 '18 at 10:33









Eddy KhalfanEddy Khalfan

61




61













  • Possible duplicate of php: loop through json array

    – Mohammad
    Nov 21 '18 at 10:38











  • I tried the answers from that with a foreach loop but I get an error Object of class stdClass could not be converted to string when execution reaches the value price, I think because it is another array

    – Eddy Khalfan
    Nov 21 '18 at 11:53













  • You need to put true in second parameter. $arr = json_decode($json, true) that cause convert json string to array. Then loop through $arr['results']

    – Mohammad
    Nov 21 '18 at 11:57













  • Thank you, that worked

    – Eddy Khalfan
    Nov 21 '18 at 12:25



















  • Possible duplicate of php: loop through json array

    – Mohammad
    Nov 21 '18 at 10:38











  • I tried the answers from that with a foreach loop but I get an error Object of class stdClass could not be converted to string when execution reaches the value price, I think because it is another array

    – Eddy Khalfan
    Nov 21 '18 at 11:53













  • You need to put true in second parameter. $arr = json_decode($json, true) that cause convert json string to array. Then loop through $arr['results']

    – Mohammad
    Nov 21 '18 at 11:57













  • Thank you, that worked

    – Eddy Khalfan
    Nov 21 '18 at 12:25

















Possible duplicate of php: loop through json array

– Mohammad
Nov 21 '18 at 10:38





Possible duplicate of php: loop through json array

– Mohammad
Nov 21 '18 at 10:38













I tried the answers from that with a foreach loop but I get an error Object of class stdClass could not be converted to string when execution reaches the value price, I think because it is another array

– Eddy Khalfan
Nov 21 '18 at 11:53







I tried the answers from that with a foreach loop but I get an error Object of class stdClass could not be converted to string when execution reaches the value price, I think because it is another array

– Eddy Khalfan
Nov 21 '18 at 11:53















You need to put true in second parameter. $arr = json_decode($json, true) that cause convert json string to array. Then loop through $arr['results']

– Mohammad
Nov 21 '18 at 11:57







You need to put true in second parameter. $arr = json_decode($json, true) that cause convert json string to array. Then loop through $arr['results']

– Mohammad
Nov 21 '18 at 11:57















Thank you, that worked

– Eddy Khalfan
Nov 21 '18 at 12:25





Thank you, that worked

– Eddy Khalfan
Nov 21 '18 at 12:25












1 Answer
1






active

oldest

votes


















0














Here's the final code that worked



foreach ($arr as $key => $jsons){
foreach ($jsons as $key => $value){
if($key == 'status'){
if (is_array($value)){
foreach ($value as $key => $val){
if($key == 'name'){
echo $val;
}
}
}else{
if($key == 'name'){
echo $value;
}
}
}
}
}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410147%2finfobip-delivery-reports-and-logs%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Here's the final code that worked



    foreach ($arr as $key => $jsons){
    foreach ($jsons as $key => $value){
    if($key == 'status'){
    if (is_array($value)){
    foreach ($value as $key => $val){
    if($key == 'name'){
    echo $val;
    }
    }
    }else{
    if($key == 'name'){
    echo $value;
    }
    }
    }
    }
    }





    share|improve this answer




























      0














      Here's the final code that worked



      foreach ($arr as $key => $jsons){
      foreach ($jsons as $key => $value){
      if($key == 'status'){
      if (is_array($value)){
      foreach ($value as $key => $val){
      if($key == 'name'){
      echo $val;
      }
      }
      }else{
      if($key == 'name'){
      echo $value;
      }
      }
      }
      }
      }





      share|improve this answer


























        0












        0








        0







        Here's the final code that worked



        foreach ($arr as $key => $jsons){
        foreach ($jsons as $key => $value){
        if($key == 'status'){
        if (is_array($value)){
        foreach ($value as $key => $val){
        if($key == 'name'){
        echo $val;
        }
        }
        }else{
        if($key == 'name'){
        echo $value;
        }
        }
        }
        }
        }





        share|improve this answer













        Here's the final code that worked



        foreach ($arr as $key => $jsons){
        foreach ($jsons as $key => $value){
        if($key == 'status'){
        if (is_array($value)){
        foreach ($value as $key => $val){
        if($key == 'name'){
        echo $val;
        }
        }
        }else{
        if($key == 'name'){
        echo $value;
        }
        }
        }
        }
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 12:26









        Eddy KhalfanEddy Khalfan

        61




        61
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410147%2finfobip-delivery-reports-and-logs%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents