How can I receive Email by using Windows Azure in my Website - php

Can I know about "Receive Email From Customer by using Windows Azure in my Website"?
Now I'm creating my company website.In this site,I will create "Contact Us" page.
This page will accept Email from my customer.
But this mail cannot not direct reach to my server by using WIndows Azure.
This page I will create with PHP language.
Can I create this function?
And how can I create this page? Do you know how to do this?

The Windows Azure environment itself does not currently provide a SMTP relay or mail relay service. Steve Marx puts together a great sample application ( available for download here) that does the
following:
It uses a third party service (SendGrid) to send email from inside
Windows Azure.
It uses a worker role with an input endpoint to listen for SMTP
traffic on port 25.
It uses a custom domain name on a CDN endpoint to cache blobs.
here’s the code that handles an incoming email:
// make a container, with public access to blobs
var id = Guid.NewGuid().ToString().Replace("-", null);
var container = account.CreateCloudBlobClient().GetContainerReference(id);
container.Create();
container.SetPermissions(new BlobContainerPermissions() { PublicAccess=BlobContainerPublicAccessType.Blob });
// parse the message
var msg = new SharpMessage(new MemoryStream(Encoding.ASCII.GetBytes(message.Data)),
SharpDecodeOptions.AllowAttachments | SharpDecodeOptions.AllowHtml | SharpDecodeOptions.DecodeTnef);
// create a permalink-style name for the blob
var permalink = Regex.Replace(Regex.Replace(msg.Subject.ToLower(), #"[^a-z0-9]", "-"), "--+", "-").Trim('-');
if (string.IsNullOrEmpty(permalink))
{
// in case there's no subject
permalink = "message";
}
var bodyBlob = container.GetBlobReference(permalink);
// set the CDN to cache the object for 2 hours
bodyBlob.Properties.CacheControl = "max-age=7200";
// replaces references to attachments with the URL of where we'll put them
msg.SetUrlBase(Utility.GetCdnUrlForUri(bodyBlob.Uri) + "/[Name]");
// save each attachment in a blob, setting the appropriate content type
foreach (SharpAttachment attachment in msg.Attachments)
{
var blob = container.GetBlobReference(permalink + "/" + attachment.Name);
blob.Properties.ContentType = attachment.MimeTopLevelMediaType + "/" + attachment.MimeMediaSubType;
blob.Properties.CacheControl = "max-age=7200";
attachment.Stream.Position = 0;
blob.UploadFromStream(attachment.Stream);
}
// add the footer and save the body to the blob
SaveBody(msg, bodyBlob, message, container, permalink);

Related

Can I use APNs Auth Key .p8 file with PHP to send iOS push notifications?

My push notifications stopped working with one of the recent updates. When I looked into it more, I discovered that Apple now lets you generate a non-expiring APNs Auth Key that works for both production and test. I have it working with the following node.js script:
var apn = require('apn');
// Set up apn with the APNs Auth Key
var apnProvider = new apn.Provider({
token: {
key: 'apns.p8', // Path to the key p8 file
keyId: '<my key id>', // The Key ID of the p8 file (available at https://developer.apple.com/account/ios/certificate/key)
teamId: '<my team id' // The Team ID of your Apple Developer Account (available at https://developer.apple.com/account/#/membership/)
},
production: false // Set to true if sending a notification to a production iOS app
});
// Enter the device token from the Xcode console
var deviceToken = '<my device token>';
// Prepare a new notification
var notification = new apn.Notification();
// Specify your iOS app's Bundle ID (accessible within the project editor)
notification.topic = '<my bundle id';
// Set expiration to 1 hour from now (in case device is offline)
notification.expiry = Math.floor(Date.now() / 1000) + 3600;
// Set app badge indicator
notification.badge = 3;
// Play ping.aiff sound when the notification is received
notification.sound = 'ping.aiff';
// Display the following message (the actual notification text, supports emoji)
notification.alert = 'This is a test notification \u270C';
// Send any extra payload data with the notification which will be accessible to your app in didReceiveRemoteNotification
notification.payload = {id: 123};
// Actually send the notification
apnProvider.send(notification, deviceToken).then(function(result) {
// Check the result for any failed devices
console.log(result);
process.exit(0)
});
Is there any way to use the new APNs Auth Key with PHP? I can call the node.js script from PHP, using exec("node app.js &", $output);, and it works, but it starts to get ugly. Should PHP still work using the old .pem file approach?

Access shared mailbox through o365 v2 api

So I got access to the new o365 v2 api and it's working pretty good so far. I am however having trouble accessing any shared inboxes.
Even worse, there doesn't appear to be any error message being returned:
#odata.context = https://outlook.office.com/api/v2.0/$metadata#Me/Messages(Subject,ReceivedDateTime,SentDateTime,Sender,From,ToRecipients,CcRecipients,BccRecipients,ReplyTo,ConversationId,IsRead,InternetMessageId
[value] =
Has anyone ever tried this?
To clarify, this isn't for exchange, but outlook.com
It seems that you were using the delegate-token to request the message from the specific user for the messages in a shared box.
The Office 365 REST API only support app-level token to get the messages from the organization. The delegate-token only could get the messages of the delegatee user.
You can also consider using the EWS to retrieve the messages of shared box as a workaround.
Here is an example for your reference:
string userName = "";
string password = "";
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new NetworkCredential(userName, password);
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
service.AutodiscoverUrl(userName, RedirectionUrlValidationCallback);
FolderId SharedMailbox = new FolderId(WellKnownFolderName.Inbox, "sharedmailbox#consoto.onmicrosoft.com");
ItemView itemView = new ItemView(10);
var results = service.FindItems(SharedMailbox, itemView);
foreach (var item in results)
{
Console.WriteLine(item.Subject);
}
And if you want the Office 365 REST API to support this feature, you can also submit the feedback from here.

How to send SMS message from Wordpress, using Twilio?

I'm trying to use Twilio in a Wordpress app and it didn't work, but my same code works in a different site/server.
I added the twilio-php folder and some PHP code to call it inside the wordpress root. I also added code to include it in the existing Wordpress PHP code, and I can't figure it out where the problem is. Can you help?
<?php
require "twilio-php/Services/Twilio.php";
/* Send an SMS using Twilio. You can run this file 3 different ways:
*
* - Save it as sendnotifications.php and at the command line, run
* php sendnotifications.php
*
* - Upload it to a web host and load mywebhost.com/sendnotifications.php
* in a web browser.
* - Download a local server like WAMP, MAMP or XAMPP. Point the web root
* directory to the folder containing this file, and load
* localhost:8888/sendnotifications.php in a web browser.
*/
// Include the PHP Twilio library. You need to download the library from
// twilio.com/docs/libraries, and move it into the folder containing this
// file.
// Set our AccountSid and AuthToken from twilio.com/user/account
$AccountSid = "********************";
$AuthToken = "*********************";
// Instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
/* Your Twilio Number or Outgoing Caller ID */
$from = '**********';
// make an associative array of server admins. Feel free to change/add your
// own phone number and name here.
$people = array(
"*********" => "******",
"**********" => "*********",
);
// Iterate over all admins in the $people array. $to is the phone number,
// $name is the user's name
foreach ($people as $to => $name) {
// Send a new outgoing SMS */
$body = "Hello this is a test message";
$client->account->sms_messages->create($from, $to, $body);
echo "Sent message to $name";
}
?>
i check the server log and notice that curel is not installed in the server then i installed and reboot the server and now it works fine thank you for your great support...Kevin Burke thanx :D

must i have FMS to publish a stream from my camera?

i am building an live streaming website and i am use
1- FMS
2- Apache webserver
i have made the subcriber and i works well .
but i need to build the publisher to allow users to broadcast thier stream from thier cameras.
i have tested a publisher which was build using actionscript and it didn't work untill i have installed the fms on my localhost , but i need a publisher which any user can use in his web browser .
my publisher :
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
connection = new NetConnection();
connection.connect("rtmp:/live");
connection.addEventListener(NetStatusEvent.NET_STATUS,onConnected);
}
private function setupVideo():void
{
//setting up outgoing devices
camera = Camera.getCamera();
camera.setMode(640,480,30);
mic = Microphone.getMicrophone();
//setting up outgoing Stream
outStream = new NetStream(connection);
outStream.attachCamera(camera);
outStream.attachAudio(mic);
outStream.publish("EraMaX-Live");
//setting up outgoing video & attach outgoing devices
outVideo = new Video();
outVideo.attachCamera(camera);
//setting up incomming Stream
inStream = new NetStream(connection);
inStream.play("EraMaX-Live");
//setting up incomming video & attach incoming Stream
inVideo = new Video();
inVideo.attachNetStream(inStream);
//wrap video object
outVideoWrapper = new UIComponent();
outVideoWrapper.addChild(outVideo);
addElement(outVideoWrapper);
inVideoWrapper = new UIComponent();
inVideoWrapper.addChild(inVideo);
addElement(inVideoWrapper);
inVideoWrapper.move(400,0);
//setting up incomming video
}
so my question must i have FMS to publish a stream from my camera to my website ?
If you want to stream live video, you need a streaming server. Not definitely FMS, you also can use Red5, Wowza, or even open source solutions such as RTMPD or RTMPLite.

Post from Flash to PHP in Facebook app

I published 2 days ago a Facebook app, it's a flash game, after the game over, the flash file POST score to my php file, Publish your score to wall if you beat your highscore, Facebook disabled the application because bad reviews from users.
How to POST from Falsh to PHP without redirecting the user, i want after the game over POST score, insert it in DB, and show the user Stream Publish popup if he want to publish to wall the score or not.
The flash game is developped by Adobe Flash CS3, AS2.
Any idea please,
To send data back to your server, you can write:
var sender = new LoadVars();
sender.x = "xxx";
sender.y = "yyy";
sender.z = "zzz";
sender.send("http://www.yourdomain.com/yourscript.php", "", "post")
To sendAndLoad
In case you want to get back data at the same time you send your data back to the server, you can use the sendAndLoad api:
var loader = new LoadVars();
loader.onLoad = function(success) {
if(success) {
// read your data here, e.g.
trace(this.x); // suppose the server send back a variable x
trace(this.y); // and a variable y
}
}
var sender = new LoadVars();
sender.x = "xxx";
sender.sendAndLoad("http://www.yourdomain.com/yourscript.php", loader, "post");
This is quite simple. Some example code here:
http://codesnippets.joyent.com/posts/show/566

Categories