I want my new project to have an API and a client working together, but I want the application to have a lot of features, one of which is sending email. I had my mind set on using Lumen (the micro-framework), but am now wondering if I should switch to a full-stack framework like Laravel, as Lumen doesn't include email functionality out-of-the-box.
Is emailing a job for the API? If so, where should it happen, just before sending a response?
My last question is quite broad but: Do I need a framework to build a REST API and can I just create it using pure PHP?
I don't expect any code from anyone, but some hints or a nudge in the right direction would be much appreciated.
Thanks a lot in advance!
You do not need a framework to send an e-mail to your clients. PHP has a built-in mail function, you can read more about it here: https://www.w3schools.com/php/func_mail_mail.asp
Because PHP is a single-threaded process, the email will be sent before the server returns a response to the client, unless you flush the buffers response before you send the mail.
You do not need a framework to build a REST API. You can do this yourself, however you will to reinvent the wheel, as many API's have great REST capabilities.
Related
I have built an ecommerce website in CakePHP and MySQL which takes orders and stores them in db. I've been told that I need to create a web service for sending notification to desktop/via email which would alert us of any order given instantly and would also provide us with order details. Do i need to study up on web services, SOAP, GET POST etc. or can I do it with some easier method? What would be a secure and fast response way of receiving such a notification from the web application? Thanks in advance :)
A webservice would be useful the other way round. If a third-party entity wishes to access your website as a service without accessing HTML pages, yes in that case, creating a webservice on your end will be useful.
I recommend you for instance to see the RESTful webservice interface to stackoverflow/stackexchange itself to understand this concept: https://api.stackexchange.com/docs.
In your case, I can't see how webservices would be involved. If you just need to send emails from your website, it can be done directly with the PHP mail() function, or using a mailer like PHPMailer.
Desktop notifications are an entirely different matter, because you need a client software.
I haven't dug pretty far in that topic myself, but here are a few pointers:
A popular Desktop Notification software for MacOSX is Growl which has been unofficially ported to Windows: http://www.growlforwindows.com/gfw/
There is a PHP API to send messages to Growl clients: http://clickontyler.com/php-growl/.
Can anyone recommend a tutorial or point me in the direction of some easily implemented .net or PHP code that i could use to setup a third party application server for C2DM.
I am a Front-End Developer with some PHP/.net experience, but very minimal Java experience, our app is setup with the required java code/classes and I have registered with C2DM, but i'm struggling with the application server part of the equation.
I would like to setup a server application that can handle form requests to send a message out to our app.
Any help or advice would be greatly appreciated!
The server part of C2DM is a piece of cake compare to the client (in my opinion). You can find below some tutorials about the server part :
One for JAVA very easy to understand even if your are not JAVA developper.
One for PHP and Zend framework.
A basic example for C# on stackoverflow
A common mistake to avoid if you want some performance : Don't connect for each message to send.
You just have to auth one time to the google server and then you can send multiple notification message.
Also don't forget that Google will periodically refresh the token in an Update-Client-Auth header. You should handle this header to keep your tokens up to date. Have look to this discussion about it
You may want to have a look at this post. It is a basic PHP implementation using curl.
I am building a server-side C2DM based on Drupal CMS.
While it is not 100% ready, if you want I can try and help you building it.
Using Drupal as the server-side, and its amazing modules such as Services and Rules, you can create a very interesting applications very easy, almost "out-of-the-box".
Im developing a webmail client using Zend framework and gmail IMAP.
Features like moving email from one folder to another ,Flagging,
mail composing,Drafts etc.
Simply it should reflect the same way as you see in the Gmail.
Technically Can any body point me towards right direction.? I mean the zend library supports REST ,JSON,IMAP,
As far as database is concerned im fine and im able to get all the data around 100 MB of data im able to store.
How should my approach be as far as architecture is concerned.Does REST & GMAIL IMAP combinedly can be used to perform manipulations ?
because always the server should always get new mail instantly may be at 5-10 min gap .
PLEASE Advise.
Also does gmail provide REST support to get new emails? OR we have to develop REST SERVER and consume the Rest client?
Also i would appreciate good hyper links to point over for kind of architecture.
Thanks
Mark
Technically Can any body point me towards right direction.? I mean the zend library supports REST ,JSON,IMAP,
These three acronyms have nothing do to with each other.
REST is an architectural philosophy.
JSON is a data encoding format.
IMAP is a protocol for accessing mailboxes.
Yes, Zend Framework has components that deal with all of these things, but that doesn't mean you have to use all of them.
If you want to access your Gmail account through IMAP, then use one of the Zend_Mail_Storage classes.
Does REST & GMAIL IMAP combinedly can be used to perform manipulations ?
If by that you mean "Can I write a RESTful application that uses IMAP to communicate to Gmail?", then the answer is yes, yes you can.
the server should always get new mail instantly may be at 5-10 min gap
It sounds like you want a cron job running to continuously poll the server for mail, instead of using an active IMAP connection live whenever the user is making requests.
Also does gmail provide REST support to get new emails?
It took them years to give us just basic IMAP support, I don't think we're going to see a RESTful API out of them any time soon. Keep in mind that they earn money based off of ad views. You aren't viewing ads when you use IMAP.
Also i would appreciate good hyper links to point over for kind of architecture.
Are you kidding? No, really, look at what you're doing. You're building a webmail client designed to access another webmail client. Do you realize how incredibly silly that is, my friend? You're re-inventing a re-invented wheel.
I don't know of a single worthwhile webmail client outside of Gmail. If you want to study the architecture of other webmail clients in PHP, then take a look at IMP (designed for PHP 4, and therefore ancient), Roundcube, or SquirrelMail. I am not responsible for any brain damage you suffer from reading the source.
I have looked on here and anddev for a suitable response, but haven't found anything suitable.
Here is the question: My friend has an instant chat application with iPhone, and since I have some basic android experience he asked me to check out "porting" it to Android. So before I set up the UI, I decided to look into php which I don't have much experience with. I know the UI will need an array to call contacts, but I'm not sure about retrieving the information from the php.
How do I know if I can use his script or not? I haven't found any good tutorials about Android and Php - has anyone found one?
I might as well learn this stuff now because my next app will require an online database to be used in it - I know his has users and passwords, and he'd like to be able to send im's between iPhone and Android clients.
Thanks for any help you may provide!
EDIT:
Yes, this issue is more related to http requests from android to a remote server; I have changed the tags and subject accordingly, but would still appreciate a guide to android-friendly php writing. Thank you!
There really isn't Android-Friendly PHP but there is mobile friendly PHP. Basically, you need your PHP scripts to emit something that is easy to parse in an application (like XML or JSON) rather than the standard HTML. After that, all you need to do is figure out what the API should look like on the server side. That is, what functions does the server need to provide and how is it going to provide them. Are you going to use simple HTTP authentication or are you going to use something more complicated?
With regards to his chat application, I would imagine that if he already has an iPhone version, then you won't need to mess with the sever side at all. All you need to do is figure out what URLs and parameters to use for what operations. You also need to ask him what data format his server uses. If it's XML, you need to find an XML parser, if it's JSON then you need to find a JSON parser etc. (there are plenty of tutorials on how to do both in Android via Google). I would start by asking him, at a high-level, not with Objective-C specifics, how his chat application communicates with the sever. You can then use that to build your application to communicate in the same manner.
I am developing social service in Drupal. There is need to send notifications to registered users.
Which option would be the easiest to integrate Drupal with and to send notifications to users?
Amazon SES,
Google App Engine,
third party provider (like Sendgrid/PostageApp/CritSend)
SES/GAE are clear winners from business point of view.
This question is about which option would be the easiest to integrate with PHP code and which would provide least headache.
Please note that third party providers are not that easy to maintain, as they might drop emails without right MTA relay (unfortunately I experienced that problem with Sendgrid and another PHP service).
I would recommend you to use SwiftMailer, a PHP library that can easily send mails via any SMTP server, SendGrid will provide you with an SMTP server that you can use I believe.
in my opinion app engine(python). only a couple lines of code to create webservice to send out e-mail in python.
you just do simple post from cURL via PHP to sent email. easy as pie. Maybe later I will post a little snippet to achieve this :P.
These days, handling email in house is a royal PITA. I recommend mailchimp instead.
Just want to throw PostageApp's hat into the ring. We've got some documentation on integration with PHP and our API is one of the cleanest and easiest to use around.
We're also exploring an integration with Amazon SES to capitalize on their great prices (And the free option!) so you might be able to use both? Happy to answer questions should you have any.