I use CURL method to post and receive response from the SMS aggregator.
$url = "https://www.smsgatewaycenter.com/library/send_sms_2.php?".$request;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);
list ($status, $returnmobileno, $statusdetails) = split('\|', $curl_scraped_page);
Now my aggregator gives response in single when I send single SMS like this
$curl_scraped_page = "success | 919********** | 659613958369444158-117942947553648183"; //THIS IS EXAMPLE
So I use list function to get unique id 659613958369444158
before the hyphen. I am all good until I get a single response but when I get response as under, am not able to get the first unique id from the response.
Multiline Response
success | 917*********| 3287615453600499019-106346209426268709
success | 919********* | 3287615453600499019-483762398162272572
success | 9196********** | 3287615453600499019-204615952244351373
Or Single Line Multi Response
success | 917*********| 3287615453600499019-106346209426268709 success | 919********* | 3287615453600499019-483762398162272572 success | 9196********** | 3287615453600499019-204615952244351373
From above given multi-line or single line multi response. I just need to catch success/error
and 3287615453600499019
and store it in my DB.
Somehow lost it even with preg_match()
.
How should I be able to achieve it?, I finally gave up after trying for 3 hours and seeking help here.