I hope this post will help someone.I need to use SendCloud to send emails through smtp.At the begin i add header in ActionMailer:
headers["X-SMTPAPI"] = JSON.dump({"to" => emails, "sub" => {"%name%" => names}})
But it can't work, and i also can't receiver the return error code through Rails.Then i find the way through communication with their support:
headers["X-SMTPAPI"] = Base64.encode64(JSON.dump({"to" => emails, "sub" => {"%name%" => names}}))
But it also can't work correctly.Then i compare the generated headers["X-SMTPAPI"] with the sent headers["X-SMTPAPI"], and found Rails insert '\n' in it for format.In the end, Mail gem convert the '\n':
def encode_crlf(value)
value.gsub!(CR, CR_ENCODED)
value.gsub!(LF, LF_ENCODED)
value
end
So, if i want it's success, i need to do like this:
headers["X-SMTPAPI"] = Base64.encode64(JSON.dump({"to" => emails, "sub" => {"%name%" => names}})).gsub!(/\n/,'')
Wow, i can send 'x-smtpapi' header in Rails successfully!
I solve it by encode and replacing '\n':
headers["X-SMTPAPI"] = Base64.encode64(JSON.dump({"to" => emails, "sub" => {"%name%" => names}})).gsub!(/\n/,'')
Related
I am trying to implement slugs in my bundle, but when i try to create a record and run my message consumer i get the following error:
Unexpected exception occurred during Direct URL generation ["exception" => Oro\Bundle\RedirectBundle\Exception\UnsupportedEntityException { …}] ["processor" => "Oro\Bundle\RedirectBundle\Async\DirectUrlProcessor","message_id" => "oro.6256de2124b630.96491198","message_body" => ["createRedirect" => true,"id" => [3],"class" => "Phpro\OroBundleBlogBundle\Entity\BlogPostCategory"],"message_properties" => ["oro.message_queue.client.topic_name" => "oro.redirect.generate_direct_url.entity","oro.message_queue.client.queue_name" => "oro.default","oro.security.token" => "organizationId=1;userId=1;userClass=Oro\Bundle\UserBundle\Entity\User;roles=ROLE_ADMINISTRATOR"],"message_headers" => ["content_type" => "application/json","message_id" => "oro.6256de2124b630.96491198","timestamp" => "1649860129","priority" => "2"],"elapsed_time" => "34 ms","memory_usage" => "107.57 MB"]
The slugs are stored, but the use of the get_slug_urls_for_prototypes twig filter results in the following error An exception has been thrown during the rendering of a template (""). Again because of the UnsupportedEntityException
Am i missing some configuration?
As mentioned in the OroCommerce documentation the entity must implement the interface to support slugs. Make sure you fulfilled this requirement.
I'm trying to make it so when someone clicks on the unsubscribe link in an email sent via the Mandrill API (using PHP) it works as described in: http://help.mandrill.com/entries/23815367-Can-I-add-an-automatic-unsubscribe-link-to-Mandrill-emails-
The *|UNSUB|* merge tag is not getting parsed. It just comes through in the the body of the email received.
Near the end of the message content ($message_content) I have:
Click here to unsubscribe.
In Gmail, the link is: Click here to unsubscribe.
(NOT a valid HREF, so Gmail just ignores the anchor tag)
In Outlook 2010 the link is: Click here to unsubscribe.
(Not a valid HREF)
Is there some merge_vars parameter I should add to the headers?
http://help.mandrill.com/entries/21678522-How-do-I-use-merge-tags-to-add-dynamic-content- mentions them, but I can't find what the parameter should be for the UNSUB merge tag.
$mandrill = new Mandrill($mandrill_api_key);
$message = array(
'html' => $message_content,
'subject' => $subject,
'from_email' => 'me#mydomain.com',
'from_name' => 'MY NAME',
'to' => $to_list,
'headers' => array('Reply-To' => 'me#mydomain.com'),
'important' => false,
'track_opens' => 1,
'track_clicks' => null,
'auto_text' => null,
'auto_html' => null,
'inline_css' => null,
'url_strip_qs' => null,
'preserve_recipients' => 0,
'view_content_link' => 1,
'tracking_domain' => null,
'signing_domain' => null,
'return_path_domain' => null,
'merge' => true,
'global_merge_vars' => array(
array(
'unsub' => 'unsub'
)
),
);
What step am I missing?
TIA!
The problem was the URL was missing a slash (http:/mydomain...)
This was caused by TinyMCE converting URLs. I added convert_urls: false to the tinymce.init and that solved my problem.
Kudos to Mandrill Support for helping me identify the problem.
I'm working with rails to create a client for the Fitbit API (very similar to twitter api) on Rails.
In my device.rb file
def fitbit_data
#client = Fitgem::Client.new (
:consumer_key => 'bb1', #I understand the security issues here and will change it for production
:consumer_secret => '81f',
:token => oauth_token,
:secret => oauth_token_secret,
:user_id => uid
)
end
It says that my syntax is wrong and asks for a ')' after :consumer_key. How do I get the syntax correct?
Note: this answer is applicable for Rails 4.1.4 and Fitgem 0.10.0.
I think the issue here is that to initialize a client, you have to pass in a hash. Additionally, I do not believe it's necessary to specify a user_id key. See my code below:
$client = Fitgem::Client.new ({ :consumer_key => ENV["FITBIT_CONSUMER_KEY"],
:consumer_secret => ENV["FITBIT_CONSUMER_SECRET"],
:token => ENV["OAUTH_TOKEN"],
:secret => ENV["OAUTH_SECRET"] })
Let me know if this helps.
I'm getting an error that I'm exceeding the number of requests allowed per session (30) when using this query (using Include instead of Customize):
ApplicationServer appServer = QuerySingleResultAndSetEtag(session => session
.Include<ApplicationServer>(x => x.CustomVariableGroupIds)
.Include<ApplicationServer>(x => x.ApplicationIdsForAllAppWithGroups)
.Include<ApplicationServer>(x => x.CustomVariableGroupIdsForAllAppWithGroups)
.Include<ApplicationServer>(x => x.CustomVariableGroupIdsForGroupsWithinApps)
.Include<ApplicationServer>(x => x.InstallationEnvironmentId)
.Load <ApplicationServer>(id))
as ApplicationServer;
Note, the error occurs on this line, which is called for each AppWithGroup within an application:
appGroup.Application = QuerySingleResultAndSetEtag(session =>
session.Load<Application>(appGroup.ApplicationId)) as Application;
However, this query (using Customize) doesn't create extra requests:
ApplicationServer appServer = QuerySingleResultAndSetEtag(session =>
session.Query<ApplicationServer>()
.Customize(x => x.Include<ApplicationServer>(y => y.CustomVariableGroupIds))
.Customize(x => x.Include<ApplicationServer>(y => y.ApplicationIdsForAllAppWithGroups))
.Customize(x => x.Include<ApplicationServer>(y => y.CustomVariableGroupIdsForAllAppWithGroups))
.Customize(x => x.Include<ApplicationServer>(y => y.CustomVariableGroupIdsForGroupsWithinApps))
.Customize(x => x.Include<ApplicationServer>(y => y.InstallationEnvironmentId))
.Where(server => server.Id == id).FirstOrDefault())
as ApplicationServer;
However, the above query causes an error:
Attempt to query by id only is blocked, you should use call
session.Load("applications/2017"); instead of
session.Query().Where(x=>x.Id == "applications/2017");
You can turn this error off by specifying
documentStore.Conventions.AllowQueriesOnId = true;, but that is not
recommend and provided for backward compatibility reasons only.
I had to set AllowQueriesOnId = true because it was the only way I could get this to work.
What am I doing wrong in the first query to cause the includes not to work?
By the way, another post had the same issue where he had to use Customize. I'd like to do this correctly though.
I'm not sure why the load isn't doing this for you, What version of raven are you on? I just tested this in Raven 2.5 build 2700 and the include is bringing back the information for me in a single request.
Anyway, with the load not working quite like i would expect, i would switch to a set of lazy queries to get what you want in 2 server round trips. http://ravendb.net/docs/2.5/client-api/querying/lazy-operations.
Another option that might work out better for you, (depending on what you are really doing with all of that data) is a transformer. http://ravendb.net/docs/2.5/client-api/querying/results-transformation/result-transformers?version=2.5
Hope that helps.
I'm using the oneAuth bundle in laravel, based on NinjAuth from Fuel by Phil Sturgeon, I believe, and trying to get the user's email address.
I've added the proper scope to my request, and the LinkedIn auth screen successfully asks for the users permission for basic profile AND email address.. so far, so good..
A possible issue is: what is the proper name of the email field?
I've found references to email-address, emailAddress, 'emailaddress`...
The docs indicate email-address, but its not working for me :)
I'm using the URL: https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url,email-address)?format=json
This is the problematic snippet from /bundles/oneauth/libraries/oauth/provider/linkedin.php
// Create a response from the request
return array(
'uid' => array_get($user, 'id'),
// 'email' => array_get($user, 'email-address)',
// 'email' => array_get($user, 'emailAddress)',
'name' => array_get($user, 'firstName').' '.array_get($user, 'lastName'),
'image' => array_get($user, 'pictureUrl'),
'nickname' => $nickname,
'description' => array_get($user, 'headline'),
'location' => array_get($user, 'location.name'),
'urls' => array(
'linkedin' => $linked_url,
),
);
If I uncomment the email field, the request fails somehow (URL still shows mysite.com/connect/callback but the favicon shows linkedin and i get ablank page in chrome: "Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.")
If the email line in the code above IS commented out, I successfully receive all the other details and a new record is added to my users table and the table oneauth_clients, but email is naturally blank..
I must be missing something simple!
Update
The request URL works with email-address, but returns a json object containing emailAddress!!
The script still dies if the return array code above includes emailAddress...
Here is someone's success story:
"I made these two changes to the library and the demo.php respectively:
const _URL_REQUEST = 'https://api.linkedin.com/uas/oauth/requestToken?scope=r_basicprofile+r_emailaddress';
$response = $OBJ_linkedin->profile('~:(id,first-name,last-name,picture-url,email-address)');
The issue was that the Request Token Call is:
https://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url,email-address)?format=json
but the json response is:
array(8) {
["emailAddress"]=>
string(18) "email#email.com"
["firstName"]=>
string(3) "Tim"
...
Note that in the first case email is named email-address, in the second emailAddress.
The secondary problem was a shortcoming of my code - now working perfectly!