Mailchimp API 3.0 does not send welcome emails - mailchimp

I am trying to subscribe user to mailchimp list, like this
$MailChimp = new MailChimp($apikey);
$result = $MailChimp->post('lists/'.$list.'/members', array(
'email_address' => $email,
'status' => 'subscribed',
'send_welcome' => true,
'double_optin' => false
));
Email was subscribed but no Welcome Email was sending to user. I turn on "Send a final welcome email" in mailchimp settings for this list. But it does not work. Please give me an advice

If you check the documentation here the request body parameter no longer accepting that parameter. It was there on API 2.0.

Related

Why am I getting an Unauthorized response with the Outlook API with Azure Active Directory?

I'm creating a task that will retrieve the messages in outlook mail with Microsoft Azure Active Directory.
I setup my azure account. Register an app, add certificate then add user to my AD. My signin method returns an access token which means signin is successful and pass the access token to outlook messages API. but the Outlook messages API returns unauthorize.
Here is my scope: email Group.Read.All Mail.Read Mail.Read.Shared Mail.ReadBasic openid profile User.Read User.ReadBasic.All Mail.ReadWrite
I used Laravel HTTP Client to send request. Hope anyone can help me, Im stuck on this problem for week
public function __construct()
{
$this->params = [
'client_id' => env('OAUTH_APP_ID'),
'scope' => env('OAUTH_SCOPES'),
'client_secret' => env('OAUTH_APP_PASSWORD'),
'username' => 'xxxxxxxx#mytenant.onmicrosoft.com',
'password' => 'xxxxxxxx',
'grant_type' => 'password',
'redirectUri' => env('OAUTH_REDIRECT_URI'),
'urlAuthorize' => env('OAUTH_AUTHORITY').env('OAUTH_AUTHORIZE_ENDPOINT'),
'urlAccessToken' => env('OAUTH_AUTHORITY').env('OAUTH_TOKEN_ENDPOINT'),
'urlResourceOwnerDetails' => '',
];
}
public function signin()
{
$url = 'https://login.microsoftonline.com/organizations/oauth2/v2.0/token';
$response = Http::asForm()->post($url, $this->params);
if($response->ok()){
$returnData = $response->json();
$mail_api = 'https://outlook.office.com/api/v2.0/me/messages';
$messagesResponse = Http::withToken($returnData['access_token'])->get($mail_api);
dd($messagesResponse);
}
}
Here is the response of my signin. I used Laravel HTTP client to send request.
And for additinal info in my granted permission
It has mentioned in the document. One of the following permissions is required to call this API:
https://outlook.office.com/mail.read
wl.imap
And the permissions in your issue like Mail.Read, Mail.Read.Shared, Mail.ReadBasic are used for Microsoft Graph API, such as Get message API.

Laravel Email validation message

I'm new to Laravel and trying to fix a email validation message. The scenario is:
If I send empty value, the validator returns a response "The User Email field is required".
If I send an invalid value like 'my_email_id' [ without # sign ], it still returns "The User Email field is required".
If I send empty value like 'my_email_id#domain', it still returns "The User Email must be a valid email address.".
Now, my question is how can I return the response "The User Email must be a valid email address." for Case 2 as well? Is there any way or is it just how Laravel does it by default?
Thanks.
You should make it with your custom validation message like this :
$rules = array(
'email'=>'required|email|unique:users'
);
$messsages = array(
'email.required'=>'The User Email must be a valid email address'
);
$validator = Validator::make(Input::all(), $rules, $messsages);
Laravel has a built-in validation for email addresses, and it just so happens that the examples directly solve your specific needs too.
You will need to look into using the email validator and adding custom error messages, both are documented in detail in the linked documentation.
However, I've gone ahead and combined the two solutions directly from the linked resource to solve your needs:
$validator = Validator::make($request->all(), [
'email' => 'required|email|unique:users',
], [
'email.required' => 'The User Email must be a valid email address.'
)];

laravel5.2 Mailgun work but not send the email

Hello I setup mailgun correctly. and did form contact us.
To send the message to my email by this code
public function send_contact_us()
{
$data = array(
'name' => Request::get('name'),'email'=>Request::get('email'),'subject'=> Request::get('subject'));
$client_m=Request::get('message');
$data_message=array('message_c'=>$client_m);
echo "we above MAIL";
Mail::send('emails.message',$data_message, function ($message)use ($data) {
$message->from($data['email'], 'E-SHOPPER');
$message->to("azharnabil013#yahoo.com")->subject($data['subject']);
});
return view('contact_us', array('title' => 'Welcome', 'description' => '', 'page' => 'contact_us','subscribe'=>'','sent'=>"Message has been sent successfuly"));
}
The code run correctly and this page display
But when I check my email I didn't find any message
I don't know why this problem .please, anyone help me.

Updating a users email address in MailChimp API V3

I am running the following code (I've hidden ID's) to update a subscriber's email address in a MailChimp list:
$mailchimp->patch('lists/1234567/members/' . md5('test#test.com'), [
'email_address' => 'new-email#newtest.com',
'status' => 'subscribed',
'merge_fields' => array(
'FNAME' => 'Ben',
'LNAME' => 'Sinclair',
),
]);
It does not seem to work. I do not receive any errors, it just does nothing.
How do you update an email address in a MailChimp list using API V3?
http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-patch_lists_list_id_members_subscriber_hash
Currently, the email address is a parameter (read only = false) in the PUT method (.../3.0/lists/{listId}/members/{md5}) that allows to change the email address of the subscriber.
I'm sending the new email in the body and MERGE0 (EMAIL) tag but using the md5 from the previous email. It is changing the email correctly.
You can change the email address when you make the request
PUT https://usx.api.mailchimp.com/3.0/lists/{list_id}/members/{subscriber_hash}
and the body was this:
{"email_address": "new#email.com"}
$List = 123456;
$subscriber_hash = md5("old#email.com")
$data = array('email_address' => "new#email.com" );
$result = $mailchimp->put("lists/$List/members/$subscriber_hash", $data);

receive more response data in ci-merchant library codeigniter

How can I receive more response data in the ci-merchant codeigniter library ?
I am using the Paypal Express checkout payment method.
And I am passing the following parameters:
$params = array(
'amount' => 100.00,
'currency' => 'USD',
'return_url' => my return url,
'cancel_url' => my cancel url );
Right now am getting just the following response
Merchant_paypal_api_response Object
(
[_status:protected] => complete
[_message:protected] =>
[_reference:protected] => 1K088384XU0947545
[_data:protected] =>
[_redirect_url:protected] =>
[_redirect_method:protected] => GET
[_redirect_message:protected] =>
[_redirect_data:protected] =>
)
How can I get the data like paypal id, shipping address, item name and other stuff that paypal returns in the DoExpressCheckoutPayment response ?
Actually, that info wouldn't come back in the DECP response. It would come back in GetExpressCheckoutDetails.
Your library should provide some way to see the RAW API requests and responses. If it's not parsing out all of the details for you you'll need to do that on your own.
This isn't exactly an answer to your question, but you should try using Omnipay instead. Omnipay is basically CI-Merchant V2 (I'm the author of both libraries).
Omnipay lets you have direct access to the raw response. E.g. you would do something like this:
$params = array( 'amount' => 1000, 'currency' => 'USD', 'returnUrl' => 'my return url', 'cancelUrl' => 'my cancel url' );
$response = $gateway->completePurchase($params)->send();
$reference = $response->getTransactionReference(); // paypal transaction id
$data = $response->getData(); // this is the raw response object

Resources