Create Campaign using API: 1007errorUnauthorized request
Hi there,
I'm trying to create a campaign using the APIs and following step by step this documentation https://www.zoho.com/campaigns/help/developers/create-campaign.html, but I have an
1007 error Unauthorized request.
I created (I'm using PHP) the code to find access token and the refresh token as documentation said with POST request; after that I used the
getmailinglists GET request to find the JSON for the 'list_details' parameter (
mandatory to create the campaign).
Now I'd like to create the campaign. here my code:
- // CREATE CAMPAIGN:
- $access_token = 1000.xxxxxxxxxxxxxxxxxxxxx ;
- $headers = array("Content-Type: application/x-www-form-urlencoded",
"Authorization: Zoho-oauthtoken $access_token");
- $list_details = '{"code":"0","uri":"/api/getmailinglists","version":"1",
"list_of_details":[{"date":"20 Feb 2018, 05:30 PM","deletable":"true","segments":{},"listdesc":"","list_created_time":"00:30 PM","noofunsubcnt":"0","lockstatus":"unlocked",
"listkey":"xxxxxxxxxxx","sentcnt":"1","owner":"Name Surname","list_campaigns_count":"1","created_time":"1519173003000",
"noofcontacts":"4","editable":"true","listname":"Test","listdgs":"xxxxxxxxxx",
"noofbouncecnt":"0","issmart":"false","list_created_date":"20 Feb 2018","listnotifications":"[]","listunino":"xxxxxxxxxx","zuid":"xxxxxxxx","servicetype":"1","sno":"2",
"is_public":"false","otherslist":"false","zx":"12698717a"}],"requestdetails":{"fromindex":1,"range":20,"total_list_count":1,"sort":"Recently Created"},"status":"success"}';
- $args = array(
'campaignname' => 'New newsletter',
'from_email' => 'name@mail.it',
'subject' => 'test html',
'content_url' => 'https://www.mysite.it/zoho/campaign.html',
'list_details' => $list_details
);
$curl_campaign = curl_init();
curl_setopt($curl_campaign, CURLOPT_URL,"https://campaigns.zoho.eu/api/v1.1/createCampaign");
curl_setopt($curl_campaign, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl_campaign, CURLOPT_HEADER, $headers);
curl_setopt($curl_campaign, CURLOPT_POST, true);
curl_setopt($curl_campaign, CURLOPT_POSTFIELDS,$args);
$result_campaign = curl_exec($curl_campaign);
curl_close($curl_campaign);
echo $result_campaign;
}
Why I still having the 1007 error?
I hope for a quick response,
thanks
Alessandra