1

This is my curl:

curl -H "Content-Type: multipart/form-data" -H "X-Token:<token>" -F payloadSend="{ "alias": "<alias>", "startDate": null, "endDate": null, "period": null, "recurrencesNumber": null, "recurrencesInterval": null, "validityPeriod": null, "sentNotify": false, "deliveredNotify": false, "msisdnToNotify":null, "sr": false, "campaignChannel": { "channelName": "UCP", "zone": null, "zoneType": null, "collectionTime": null }, "campaignMessage": { "messageType": null, "messageContent": "<testo>", "template": null, "file": "string", "msisdn": "<msisdn>", "listMsisdn": null, "fileMsisdn": "null", "name": null, "surname": null, "extra": null, "status": "string", "delivered": "string" } };type=application/json" "https://channel-ssc-api.services.smb.telecomitalia.it/channels/UCP/campaigns?destination =msisdn&message=static&delivery=immediate&type=single" --trace- ascii -

Its my function:

$client = new Client();


        $payload = [
            "alias" => "Something",
            "startDate" => null,
            "endDate" => null,
            "period" => null,
            "recurrencesNumber" => null,
            ...
            ]
        ];

        $params = [
            'destination ' => 'msisdn',
            'message' => 'static',
            'delivery' => 'immediate',
            'type' => 'single',
        ];
        //$curl->setHeader("Content-Type", "multipart/form-data");
        $url = "https://channel-ssc-api.services.smb.telecomitalia.it/channels/UCP/campaigns?destination=msisdn&message=static&delivery=immediate&type=single";
        //$url = "https://channel-ssc-api.services.smb.telecomitalia.it/channels/UCP/campaigns";
        $headers = [
            "X-Token" => $this->token,
            'Content-Type' => "multipart/form-data"
        ];
        $res = $client->request('POST', $url, [
            'headers' => $headers,
        ]);

I don't understand how to integrate payloadSend into the code PHP. Important that at the end of the payload there is written type: application / json Thank you in advance. I've been banging with this problem for hours

  • Will this help? https://stackoverflow.com/questions/11079135/how-to-post-json-data-with-php-curl – Niv Apo Jan 07 '20 at 19:37

0 Answers0