I'm writing a CMS application in PHP and one of the requirements is that it must be able to interface with the customer's Exchange server. I've written up this functionality a few times before and have always used WebDAV to do it, but now I'm leaning away from that.
I will be running the site on IIS OR Apache (no preference) on Windows server 2008. A few things I would need to do include adding contacts to a given user's address book, sending emails as a given user and running reports on contacts for a user.
All of this is pretty easy to do with WebDAV, but if there is a better way that doesn't require any functionality that is likely to be deprecated any time soon.
Any ideas?
Update:
Justin, I love the idea of using com objects, I just worry about maintaining a 3rd product to make everything work...
John, I can write a web service in C# to interface with for these functions and access it with my PHP app, but it's also a little bit out of the way.
So far, I'm not 100% convinced that either of these is better than WebDAV...
Can anyone show me where I'm being silly?
Update as of 2020:
Over a decade since this question and things have moved on. Microsft now has a Rest API that will allow you to easily access this data.
Original Answer
I have not used PHP to do this but have experience in using C# to achieve the same thing.
The Outlook API is a way of automating Outlook rather than connecting to Exchange directly. I have previously taken this approach in a C# application and it does work although can be buggy.
If you wish to connect directly to the Exchange server you will need to research extended MAPI.
In the past I used this wrapper MAPIEx: Extended MAPI Wrapper.
It is a C# project but I believe you can use some .NET code on a PHP5 Windows server. Alternatively it has a C++ core DLL that you may be a able to use. I have found it to be very good and there are some good example applications.
Sorry for the delay no current way to keep track of posts yet.
I do agree adding more layer on to your application and relying on 3rd party code can be scary (and rightfully so.)
Today I read another interesting post tagged up as MAPI that is on a different subject. The key thing here though is that it has linked to this important MS article. I have been unaware of the issues until now on using managed code to interface to MAPI although the C++ code in the component should be unaffected by this error as it is unmanaged.
This blog entry also suggests other ways to connect to MAPI/Exchange server. In this case due to these new facts http://us3.php.net/imap may be the answer as suggested by the other user.
Is your customer using Exchange 2007? If so, I'd have a look at Exchange Web Services. If not, as hairy as it can be, I think WebDAV is your best bet.
Personally I don't like using the Outlook.Application COM object route, as its security prompts ("An application is attempting to access your contacts. Allow this?", etc.) can cause problems on a server. I also think it would be difficult to accomplish your impersonation-like tasks using Outlook, such as sending mail as a given user.
I have released an open-source MIT licensed library that allows you to do some basic operations in PHP using Exchange Web Services.
Exchange Web Services for PHP
I have only tested it on Linux but I don't see any reason why it wouldn't work on a Windows installation of PHP as well.
I can't recommend Dmitry Streblechenko's Redemption Data Objects library highly enough. It's a COM component that provides a sane API to Extended MAPI and is a joy to use. The Exchange API goalposts move from one release to the next: “Use the M: drive! No, use WebDAV! No, use ExOLEDB!… No, use Web Services!” with the only constant being good old MAPI.
I'm not a PHP dev but Google says that PHP 5+ can instantiate COM components. If you can install Outlook on a box you could write a PHP web service around the COM component to handle the requests you need.
$outlook = COM("Outlook.Application")
Outlook API referance
I would recommend using "PHP Exchange Web Services" or short php-ews.
Fair amount of documentation under the wiki, helped me a lot.
This Zarafa PHP MAPI extension looks like it could work.
I would look into IMAP
IMAP, POP3 and NNTP
https://github.com/Garethp/php-ews
It was last updated 3 months ago so it is maintained
Related
In the application I've written there is a whole class that only takes in some parameters, eventually fetches the db for other parameters, and then returns the results to the asking class. It only handles data, so it would be perfect to "outsurce" those functions to something more efficient than PHP.
I've read the official php faq page on "PHP and COM", and seen that it is not possible to run a precompiled dll from php.
So, do you think it is possible and worth to do it with some other methods? And how would you do it?
Maybe PHP/Java Bridge / RESTful WS could do, but still java does not sound like the best option (according to this post it's "clunky")
HipHop would be a great solution, but as of now it's way too early to use it in production for my needs.
All the solutions listed here seem to be aimed at creating an .exe file for making a standalone win app, whereas my app is hosted on a centOS server and I haven o need to port it to windows (or at least that's not my intention right now).
I use C++ and RabbitMQ to tie it together. I've also had success, when there wasn't much of a scope for the project, at using Redis as a tie in.
Can't say enough good things about using a message bus to separate processes (like RabbitMQ).
If you're just getting started with RabbitMQ, I'd highly recommend RabbitMQ in Action.
You don't have to use C++ though. That's one of the major benefits of using message buses; you can substitute later, if need be (and the API stays the same). Here are a list of clients that can receive and post messages to RabbitMQ: http://www.rabbitmq.com/devtools.html
Insert favorite, high-performance language here.
We have an AS/400 system. I am asked to look for a way to call RPG programs from PHP on our Apacher server. The only solution i found was installing zend server to AS/400 and using i5 PHP API Toolkit. Since I don't know how to use AS/400 and don't have access i haven't tried it yet.
We can connect to database and read, write from php. I am asking if there is any way to call a rpg program on our system from php code and send parameters, retrieve output.
I found there is JTOpen for Java. Maybe same thing for Php would work.
You can execute host programs as if they were stored procedures.
For more information:
iSeries Access ODBC: Stored Procedures
Today the easiest answer is the open-source PHP Toolkit for IBM i that is shipped with Zend Server and also is available for free download.
I'm not an iSeries developer so I can't give detailed instructions but it should be possible to use the CGIDEV2 library (http://en.wikipedia.org/wiki/Cgidev2) to expose RPG functionality over HTTP. This would make your RPG functionality easily accessible to PHP and any other environment which can act as a web client. The caveat is that you need to make source level modifications to the RPG in question which may not suit your working arrangements.
Edit: Sorry, I just noticed that you said you didn't have access to the iSeries directly so this won't be a solution for you,
I am working on a task where it is required to distribute live data (being fetched from some other server) to client using sockets. We user drupal as a framework and thus my choice of PHP.
1)I want to know the major factors that should be taken into consideration while developing this server.Like security,authentication,load etc and how should i approach this.Is there any blog/article that could be of help.
2)Is there a better choice than PHP for this?
3)ALSO is there any drupal module that could assist me in this.
I can think about one issue when you are talking about several servers connecting to you, you may want to conceder a nonblock mode.
Because when you are working with blocking mod, each server can connect at the time, meaning that there will be delay delivering the message.
http://il2.php.net/manual/en/function.socket-set-nonblock.php
I think java would be better choise, multi thread may help here.
from my point of view, this is something that you need to develop your self, socket programming needs a lot of attention.
Drupal is a Web CMS, it can be used as framework for advanced web features or light to medium web application that fits well in the traditional HTTP request paradigm. IMHO, distributing live data from multiple servers to client using sockets doesn't fit with the base assumption behind Drupal's design.
PHP can be used to write socket server. It used to be un-common, but it is becoming more and more available. ReactPHP is a non-blocking I/O library/framework suited for socket programing. Racthet is a websocket server in PHP using ReactPHP.
In any case, this would ne nothing like developing a web application with RoR, Drupal, Django, Symfony, etc.
If integration with a Drupal website is required, the Service module is a nice solution to provides a REST or XML-RPC API. Or course, direct access to Drupal's MySQL database is also an option but will probably require more knowledge of the used Drupal modules since you will have to replicate their behaviors and understand how they manage their data (for instance, how a particular CCK field is stored in your database).
Note: Previous version of this answer included reference to the following solutions in other languages: Twisted (Python), EventMachine (Ruby) and Node.js (JavaScript). These are all valid solutions when PHP is not required.
Previous version of the answer also referenced phpsocketdaemon, but nowadays ReactPHP is a more clean and robust solution.
Background: Experienced PHP developer with a mostly *nix background.
I'm writing a PHP application that needs to interact with a proprietary 3rd party system. The 3rd party system is Windows only. The PHP application will be living on a separate Linux based system
The 3rd party application has been described as having a "COM API" that I'll need to talk to from the PHP application. What does this look like architecturally speaking? I'm starting with the COM section of the PHP manual, but I have specific questions.
Specific Questions:
Can I talk directly to a COM API from a PHP application running on another server? If so, how? (what PHP extensions would I need, or what protocols/PHP functions would I be using to talk to the API)
If the answer to number 2 is no, I'd assume I'd need some kind of application on the Windows machine that can talk to COM, and then a service on the windows machine I can hit with PHP. Are there prebuilt frameworks for this kind of thing?
Is this all nonsense and/or did I say something exceedingly stupid? (Quite possible, as I'm a little fuzzy on what "COM" does and doesn't cover)
I'm obviously not looking for a full solution here, I'm just trying to get a general idea of what is and isn't possible and what kind of things I'll want to Google for.
Thanks!
Normally a "COM API" is contained in a DLL file or Active X control(kinda like a dll file) and you reference that from a windows application which will load the COM dll just like any other DLL. COM was really just an attempt at making DLLs easier to reuse as well as address many other issues with DLLs.
So the answer to number 1 is no.
The answer to number 2 is yes. I would personally create a wrapper for the COM API with WCF. WCF is basically a Microsoft .NET technology for building web services. This would make consuming the api in PHP much easier. The biggest hurdle will be learning WCF as well as figuring out how you want to map members in the COM api to members in your web service, since the data types will probably need to be transformed in some way. The WCF application can be hosted as a windows service or hosted in IIS, so this sort of kills both birds in one stone.
You could optionally use the older Web Services in .NET that have been around before WCF, I just personally liked WCF better because it was more flexible. If you click enough times through the microsoft's extremely user unfriendly webcast site you can download a series of videos on WCF:
http://www.dasblonde.net/2007/06/24/WCFWebcastSeries.aspx
-3 No I don't think so.
Being as stubborn as it gets, I'm building my own PHP-based CMS and framework (named RAmen/FSM just for the kicks) that has been deployed multiple times for my customers. Now, I'm going to develop a support ticket application for it that I will deploy on a 'central' server for convenience of maintenance.
Now, I've looked into SOAP services and was happy until I got to WSDL generation in PHP and in itself. So, what would you suggest for me to 'securely' (as in, no https) manage this with SOAP-like simplicity on the client side ($support->newTicket), without the WSDL headaches on the server side? Or should I –gasp– stop being so stubborn and just go with a PHP library (in which case, please do recommend!)
Thank you, fellow pastafarians/spagnostic coders!
PHP has a native SOAP extension, that automates client as well as server. It is a little buggy in some places, but still better than nusoap (IMHO).
That said, I would never chose SOAP if I had any bearing on the decision. Use xml-rpc or a rest-based approach.
I have a similar question, whether to use REST or SOAP. I am using REST but that is beacuse i want a simple API like function not so much the rigid functionality associated with REST.
That being said here is a nice little library to get you started on SOAP
http://sourceforge.net/projects/nusoap/
By the sounds of it SOAP is actually what you want. you will fin it a bit easier to implement as you get the domain models from the WSDL.