分类 Windows Phone 下的文章

CURLOPT_CONNECTTIMEOUT 和 CURLOPT_TIMEOUT的区别

There's a very distinctive difference between these two configurations within cURL. I'll try to definethemfor you, and then provide you a very common example which I shareto people who I teach about cURL.

CURLOPT_CONNECTTIMEOUT is designed to tell the script how long to wait to make a successful connection to the server before starting to buffer the output. Adestination's server which may be overloaded, offline or crashedwould probably make this setting becomeuseful.

CURLOPT_TIMEOUT isdesigned to tell the script how long to wait to receive acompletely buffered output from the server. A destination's hugefile, slow connection speeds or slow rendering would probably makethis setting become useful.

A good example of where these will both apply to, is when you'retelling cURL to download a MP3 file. CURLOPT_CONNECTTIMEOUT would be set at about 10 seconds which would mean that if no response is provided within 10 seconds then the script will abort, and CURLOPT_TIMEOUT would be set at about 100 seconds which would mean if the MP3 has not downloaded within 100 seconds then abort the script. It's the best way of explaining it to developers.

CURLOPT_CONNECTTIMEOUT:服务器没有相应的超时时间。

CURLOPT_TIMEOUT:服务器连接的超时时间。

最近性能优化中,发现接口请求有的会长达3s,检查框架代码后发现是由于没有设置超时时间导致。

相关资料:
What the different CURLOPT_CONNECTTIMEOUT and CURLOPT_TIMEOUT

离线升级到Tango

前提手机目前已是7720Mango版本,可按下面流程离线升级到Tango。

7720升级到7740,参考教程:
http://www.wpxap.com/thread-212638-1-1.html

7740升级到8107,参考教程:
http://www.wpxap.com/thread-259138-1-1.html

8107升级到8112,8112升级到8773,参考教程:
http://www.wpxap.com/thread-432749-1-1.html

PHP版的Windows Phone推送功能

经过几天的捣鼓,终于搞定了PHP版的Windows Phone推送功能(Toast通知)。

推送流程:
1.手机上部署XAP,然后获取到手机的通知管道URI。
2.通过通知管道URI向MPNS发送通知数据。
3.MPNS向手机推送通知。

推送流程

具体参考:http://msdn.microsoft.com/zh-cn/library/ff402558(v=vs.92)

推送成功效果图:
通知成功

PHP代码:

/**
*Windows Phone 7 Push Notification in php by Rudy HUYN
**/
final class WindowsPhonePushDelay
{

const Immediate=0;
const In450Sec=10;
const In900Sec=20;

private function __construct(){}
}

class WindowsPhonePushNotification
{
private $notif_url = '';

function WindowsPhonePushNotification($notif_url)
{
$this->notif_url = $notif_url;
}

/**
* Toast notifications are system-wide notifications that do not disrupt the user workflow or require intervention to resolve. They are displayed at the top of the screen for ten seconds before disappearing. If the toast notification is tapped, the application that sent the toast notification will launch. A toast notification can be dismissed with a flick.
* Two text elements of a toast notification can be updated:
* Title. A bolded string that displays immediately after the application icon.
* Sub-title. A non-bolded string that displays immediately after the Title.
*/
public function push_toast($title, $subtitle,$delay = WindowsPhonePushDelay::Immediate, $message_id=NULL)
{
$msg =    "" .
"" .
"" .
"".htmlspecialchars($title)."" .
"".htmlspecialchars($subtitle)."" .
"" .
"";

return $this->push('toast',$delay+2,$message_id, $msg);
}

/**
*A Tile displays in the Start screen if the end user has pinned it. Three elements of the Tile can be updated:
*@background_url : You can use a local resource or remote resource for the background image of a Tile.
*@title : The Title must fit a single line of text and should not be wider than the actual Tile. If this value is not set, the already-existing Title will display in the Tile.
*@count. an integer value from 1 to 99. If not set in the push notification or set to any other integer value, the current Count value will continue to display.
*/
public function push_tile($background_url, $title, $count, $delay = WindowsPhonePushDelay::Immediate,$message_id=NULL)
{
$msg =     "" .
"" .
"" .
"".htmlspecialchars($background_url)."" .
"$count" .
"".htmlspecialchars($title)."" .
"" .
"";

return $this->push('token',$delay+1, $message_id,$msg);
}

/**
* If you do not wish to update the Tile or send a toast notification, you can instead send raw information to your application using a raw notification. If your application is not currently running, the raw notification is discarded on the Microsoft Push Notification Service and is not delivered to the device. The payload of a raw notification has a maximum size of 1 KB.
*/
public function push_raw($data, $delay = WindowsPhonePushDelay::Immediate,$message_id=NULL)
{
return $this->push(NULL,$delay+3,$message_id, $data);
}

/**
*@target : type of notification
*@delay : immediate, in 450sec or in 900sec
*@message_id : The optional custom header X-MessageID uniquely identifies a notification message. If it is present, the same value is returned in the notification response. It must be a string that contains a UUID
*/
private function push($target,$delay,$message_id,$msg)
{

$sendedheaders=  array(
'Content-Type: text/xml',
'Accept: application/*',
"X-NotificationClass: $delay"
);
if($message_id!=NULL)
$sendedheaders[]="X-MessageID: $message_id";
if($target!=NULL)
$sendedheaders[]="X-WindowsPhone-Target:$target";

$req = curl_init();
curl_setopt($req, CURLOPT_HEADER, true);
curl_setopt($req, CURLOPT_HTTPHEADER,$sendedheaders);
curl_setopt($req, CURLOPT_POST, true);
curl_setopt($req, CURLOPT_POSTFIELDS, $msg);
curl_setopt($req, CURLOPT_URL, $this->notif_url);
curl_setopt($req, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($req);
curl_close($req);

$result=array();
foreach(explode("\n",$response) as $line)
{
$tab=explode(":",$line,2);
if(count($tab)==2)
$result[$tab[0]]=trim($tab[1]);
}
return $result;
}
}

代码来自:http://jpsolution.wordpress.com/tag/push-notification-for-windows-phone-7-in-php/
其他参考资料:http://www.daveamenta.com/2010-11/send-push-notifications-to-windows-phone-7-from-php/

微信2.1来了~

WP7版的微信2.1来了,暂时还未上线市场,可以到微信官网(www.weixin.com)下载。

[gallery link="file"]

图钉应用体验

图钉,是Windows Phone上类instagram的一款应用。

官方网站:http://www.tuding001.com/
官方网站是抄袭开心网么,001的后缀现在很流行么?域名给我的第一印象就不太好。

官方首页:

电脑端给我的感觉就是挫,设计的很挫,比如下面的提示。

下面进入手机端的表现。
打开应用的主屏图片,还是不错的,图中应该是Lumia 800。这款机子哥等了半年没进国内,实在忍不住买了个一代机玩玩。

首页显示。

处理图片,同时提供了滤镜、旋转和虚化操作。
这里有一处不足就是选择图片时需要截取成正方形,很多图片截取成正方形根本就没法看了。或许就是截取的原因,上传的速度很快。

虚化还同时提供了三种模式(中心、横向、竖向)。

上传图片同时支持腾讯、新浪、搜狐、网易微博和人人、开心网。

上传同时支持LBS、tag和@好友。
LBS有个问题:我一开始选择允许获取位置,后来我在设置里取消了定位,但是每次上传图片都还是会自动加上位置,每次都需要手动点击去除。
tag需要单独点击在另一个页面设置,同时tag项是系统定死的,无法自定义,此点需要改进。为什么不能直接在上传图片的页面设置tag,同时支持自定义呢?

退出时的提示。

不知道为什么退出这里的两个标点符号和汉字很不搭,不知道是不是因为符号是英文下的原因。

疑问:
图钉这个应用我之前安装使用过一次,当时注册了个帐号,但是我记得我没有关注任何人,只是注册了个帐号体验了下,然后感觉没什么意思就删掉了。
后来无聊就从市场里下载下来使用。在电脑登录图钉后发现我居然关注了几十个帐号,怀疑是系统自动替我关注的,这点让我很是反感。

体验心得:
对于图钉这样一款图片分享应用,你不妨一试,但是不要抱太大希望。
细节体验跟instagram差太多了,还是期待instagram官方的应用吧。