You might be considering to use SocialEngine's APIs for sending Emails. I came across the same situation where I needed to send Email with the system. I didn't find straight forward answer and documentation. Also, given the third-party plugins that I have installed including those related to Emails from such vendors as SocialEngineAddOns ©, I had some difficulty and confusion with regard to that.
Finally, by studying their code I found a method "sendSystem" from their API that does send Email. An example where an Email is sent to the viewer is as follows: $buyer = Engine_Api::_()->user()->getViewer(); Engine_Api::_()->getApi('mail', 'core')->sendSystem($buyer, 'sitestoreproduct_order_place_by_member', [ 'host' => $_SERVER['HTTP_HOST'], 'email' => $buyer->email, 'date' => time(), 'recipient_title' => $buyer->getTitle(), 'recipient_link' => $buyer->getHref(), 'recipient_photo' => $buyer->getPhotoUrl('thumb.icon'), 'object_link' => 'https://zoodbashcity.com/stores/products/account/menuType/my-orders', 'queue' => false, ]);
The first argument to this method is the user and the second argument is apparently a template or something defined somewhere as text file. I'm not sure about that. For example, when you choose sitestoreproduct_order_place_by_member, an Email like the following (including placeholders) is sent to the specified address:
Hi Jack, Your order [order_no] from store [object_name] was placed successfully. Please see your invoice below. [order_invoice] Best Social Network Admin If you want to add something to the explanations, please let me know in the comments below.
0 Comments
In the previous session, we discussed the need to post something to our social network via REST API. You saw that we could not do this with SocialEngine alone. So, we took advantage of a third-party plugin SocialEngineAddOns' REST API. This API allows us to do things like posting feeds. In part two of the series I'm going to cover which parts of this API we will need for our purpose.
First, the route to which we will direct our requests is: /api/rest/feeds/post Arguments that we will need to post to this route are as follows: oauth_consumer_key=xxxxxxxxx oauth_consumer_secret=xxxxxxx oauth_token=xxxxxx oautu_secret=xxxx oauth_view=everyone body=This is a test post Note that, you can get oauth_consumer and oauth_token by calling /api/rest/login with appropriate parameters. Or, if we are already logged in, I assume we can use the existing tokens. The table for consumers and tokens are: engine4_siteapi_oauth_consumers engine4_siteapi_oauth_tokens I have tested the above parameters with RESTing and it works. All we have to do now is do the posting in our controller code. In the next session, I will cover that. Imagine we want to post stuff like text and images to our SocialEngine site using only code. This means no user interaction is involved. Our code has to log in, get required tokens and then post something on behalf of the user. In this post, I am trying to discuss this and come up with a solution for it.
As far as I know, we cannot do this with SocialEngine per se. However, there are third-party plugins that let us do such advanced stuff with a dedicated REST API. There is a plugin from SocialEngineAddOns, a reputable plugin developer for SocialEngine called Advanced REST API. There is a pretty good documentation for the named plugin that you can check out at: mobiledemo.socialengineaddons.com/public/apidocumentation.html Under Activity Feeds, there is a method "activity/post" which allegedly posts a new feed to the website using the "multipart/form-data" format. Typically you will at least need to provide two keys (that you create in the plugin's settings) along with other parameters when making API calls. These are oauth_consumer_key and oauth_consumer_secret that you provide in url. For example, http://example.com/api/rest/advancedvideos/browse?oauth_consumer_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&oath_consumer_secret=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Now, if we put activity/post in the same format, it gives the following error: {"status_code":400,"error":true,"error_code":"invalid_method","message":"Incorrect method."} I'll keep working on this and update the post if I come up with a solution. If you have opinions or experience doing this already, please feel free to share in the comments. So, you are in an action within a controller and you want to access the current module name and action, so that you can use it in your code instead of hardcoding it. A very convenient method to help you do that is $this->getAllParam('param);
class AdvancedPlugin_ApiController extends Core_Controller_Action_Standard { public function indexAction() { $moduleName = $this->getParam('module'); $controllerName = $this->getParam('controller'); $actionName = $this->getParam('action'); } } |
AuthorI'm Mehdi, a web and mobile app developer ArchivesCategories |