3
を使用して、URL HTTPGETからのimg得ることができない私はWP7:webclient.OpenReadAsync
getvmsimg
説明、Windowsのphone7のappplicationに、このAPIから画像を取得する必要があります:
API for get variable message sign (VMS) as img
URL:
http://athena.traffy.in.th/apis/apitraffy.php?api=…&id=…[w=...]&[h=...]
フォーマット:
Image: PNG
HTTPメソッド:
GET
が認証を必要とする:限られた
true
API率:
unlimited
とこれは私のコードです 私は別のAPIでセッションキーを取得しなければなりません(完全に問題ありません)、次にセッションキーをhttpget urlのパラメータとして使用する必要があります。 私の鍵が正しく100%であることを確認しました。 しかし、それはでエラー "image.SetSource(e.Result);"(不明なエラー)。
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 OpenReadCompletedEventHandler(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、男
ブラウザで2番目のURLを訪問すると成功しますか? – AnthonyWJones
はい、img(.png)が正常に表示されます。 – Ratchapol
Fiddlerツールを掘り下げ、そのURLを使用しているときのブラウザのHTTP会話を調べ、Silverlightアプリケーションが同じURLを取得しようとしている会話と比較します。 – AnthonyWJones