开发者

WP7: can't get img from httpget url using webclient.OpenReadAsync

I need to get image from this API on Windows phone7 appplication,

getvmsimg

Description :

API for get variable message sign (VMS) as img

URL:

http://athena.traffy.in.th/apis/apitraffy.php?api=…&id=…[w=...]&[h=...]

Formats:

Image: PNG

HTTP Method:

GET

Requires Authentication :

true

API rate limited :

unlimited

and this is my code I have to get a session key by another API first(Completely,No problem) and then i have to use the session key as a parameter in httpget url. my key is correctly 100 percent, i have checked. but It error at "image.SetSource(e.Result);" line (Unspecified error).

public intsign()
{
    InitializeComponent();


    client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
    client.DownloadStringAsync(new Uri("http://api.traffy.in.th/apis/getKey.php?appid="+appid));

}

void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    rd = e.Result;
    sessionkey = MD5Core.GetHashString(appid + rd) + MD5Core.GetHashString(hiddenkey + rd);
    //MessageBox.Show(sessionkey);

    client2.OpenReadCompleted += new OpenR开发者_运维知识库eadCompletedEventHandler(client2_OpenReadCompleted);
    client2.OpenReadAsync(new Uri("http://athena.traffy.in.th/apis/apitraffy.php?api=getvmsimg&key=" + sessionkey + "&appid=" + appid + "&id=1&h=480&w=480"),client2);
}

void client2_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
    BitmapImage image = new BitmapImage();
    image.SetSource(e.Result);
    intsignimg.Source = image;
}

thx, guy


Did you try to write the entire stream (with a buffer or else) into a MemoryStream and then use that MemoryStream instead of using directly the resulting stream ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜