从Windows Live获取个人资料图片网址

时间:2015-12-09 16:18:19

标签: php json api live

在php中我尝试得到这样的个人资料图片:

$picture = file_get_contents('https://apis.live.net/v5.0/'.$tmp['id'].'/picture?type=medium&access_token='.$accesstoken);

但如果我这样做:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $t);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$a = curl_exec($ch);
if(preg_match('#Location: (.*)#', $a, $r))
$picture = trim($r[1]);

在这里,我什么都没得到,没有任何回报,很奇怪。

这是live api的链接:https://msdn.microsoft.com/en-us/library/hh243648.aspx#user

他们说:

  

注意要将GET调用重定向到用户图片的URL,您可以调用/ me / picture或/ USER_ID / picture。

我也试过了https://apis.live.net/v5.0/me/picture =>但也不起作用

我根本不明白,任何想法?

以下是API范围:

范围= wl.emails + wl.basic

我用curl:

替换了file_get_contents
/// <summary>  
/// Allows binding a property to the header text. Works with the clipboard copy mode - IncludeHeaders.  
/// </summary>  
public static class DataGridHeaderTextAttachedProperty  
{  
  private static readonly Type OwnerType = typeof(DataGridHeaderTextAttachedProperty);  
  public static readonly DependencyProperty HeaderTextProperty = DependencyProperty.RegisterAttached("HeaderText", typeof(string), OwnerType, new PropertyMetadata(OnHeaderTextChanged));  

  public static string GetHeaderText(DependencyObject obj)  
  {  
    return (string)obj.GetValue(HeaderTextProperty);  
  }  

  public static void SetHeaderText(DependencyObject obj, string value)  
  {  
    obj.SetValue(HeaderTextProperty, value);  
  }  

  private static void OnHeaderTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)  
  {  
    var column = d as DataGridColumn;  
    if (column == null) return;  
    column.Header = GetHeaderText(column);  
  }  
}

现在我得到这张图片网址:

https://cid-fbf213653beb66a0.users.storage.live.com/users/0xfbf213653beb66a0/myprofile/expressionprofile/profilephoto:UserTileMedium

现在:

  • 如果我在浏览器中打开此网址:KO(白页)

  • 如果我删除上面的粗体部分,浏览器会下载图片(如果我添加.png,我可以阅读。)

有没有办法让我无需下载即可获得图片?

0 个答案:

没有答案