2

私はFacebook SDKのOPを取得して実行しています。アルバムのすべての写真を取得しようとしています。現在、私はこれを使用しています:

NSString *S = [[NSString alloc] initWithFormat:@"%s%@%s","https://graph.facebook.com/",albumID, "/photos"];
[facebook requestWithGraphPath:S andDelegate:self];

私も結果を取得し、それを写真または写真 ID の配列に解析しようとします。しかし、私は何時間もウェブを検索しようとしましたが、解決策を見つけることができません. 私は何を間違っていますか?

- (void)request:(FBRequest *)request didLoad:(id)result


        for (NSDictionary *anAlbum in [result objectForKey:@"data"]) {
            [arrayAllPhotos addObject:[anAlbum objectForKey:@"id"]];

            NSString *url = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture",[arrayAllPhotos objectAtIndex:counter]];

            UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
        }
}

これは、Facebook から返された JSON です。前もって感謝します!

{
   "data": [
      {
         "id": "244119762368747",
         "from": {
            "name": "Eindhovens Studenten Corps Intro",
            "category": "Non-profit organization",
            "id": "235447296569327"
         },
         "picture": "http://photos-g.ak.fbcdn.net/hphotos-ak-snc7/392553_244119762368747_67274374_s.jpg",
         "source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/392553_244119762368747_67274374_n.jpg",
         "height": 480,
         "width": 720,
         "images": [
            {
               "height": 1365,
               "width": 2048,
               "source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s2048x2048/392553_244119762368747_67274374_n.jpg"
            },
            {
               "height": 640,
               "width": 960,
               "source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/392553_244119762368747_67274374_n.jpg"
            },
            {
               "height": 480,
               "width": 720,
               "source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/392553_244119762368747_67274374_n.jpg"
            },
            {
               "height": 320,
               "width": 480,
               "source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s480x480/392553_244119762368747_67274374_n.jpg"
            },
            {
               "height": 213,
               "width": 320,
               "source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s320x320/392553_244119762368747_67274374_n.jpg"
            },
            {
               "height": 120,
               "width": 180,
               "source": "http://photos-g.ak.fbcdn.net/hphotos-ak-snc7/392553_244119762368747_67274374_a.jpg"
            },
            {
               "height": 86,
               "width": 130,
               "source": "http://photos-g.ak.fbcdn.net/hphotos-ak-snc7/392553_244119762368747_67274374_s.jpg"
            },
            {
               "height": 86,
               "width": 130,
               "source": "http://photos-g.ak.fbcdn.net/hphotos-ak-snc7/s75x225/392553_244119762368747_67274374_s.jpg"
            }
         ]
4

1 に答える 1

1

の代わりにarrayAllPhotos使用するオブジェクトを追加する場合:sourceid

[arrayAllPhotos addObject:[NSUrl urlWithString:[anAlbum objectForKey:@"source"]]];

ああ、これらの画像を使用したい場合は、次のようにします。

UIImage *image = [[UIImage imageWithData:[NSData dataWithContentsOfUrl:[arrayAllPhotos objectAtIndex:indexOfObjectYouWant]]]];

それが役に立てば幸い

于 2013-01-22T01:29:23.003 に答える