2013-06-17 5 views
2

에 의해 게시하지 내가 설치 한페이스 북 페이지 피드에 사진을 게시하는 방법 - 다른 사람

지금 내가 코드를 아래

enter image description here

코드에와 같이 벽에 게시 할 수 있어요 페이스 북 SDK를 메시지 위 게시

 FacebookClient myClient = new FacebookClient(srAcceToken); 
     var dicParams = new Dictionary<string, object>(); 
     dicParams["message"] = "trial message"; 
     dicParams["caption"] = string.Empty; 
     dicParams["description"] = string.Empty; 
     dicParams["name"] = "deneme 123"; 
     dicParams["req_perms"] = "publish_stream"; 
     dicParams["scope"] = "publish_stream"; 
     dicParams["access_token"] = srAcceToken; 
     var publishResponse = myClient.Post("/" + srPageId + "/feed", dicParams); 

이제 이미지를 게시하려고 할 때 문제가 발생합니다. 난 결과

  var mediaObject = new FacebookMediaObject 
     { 
      ContentType = "image/jpeg", 
      FileName = "pokemon.jpg" 
     }.SetValue(File.ReadAllBytes(Imagepath)); 

     FacebookClient myClient = new FacebookClient(srAcceToken); 
     var dicParams = new Dictionary<string, object>(); 
     dicParams["message"] = "trial message"; 
     dicParams["caption"] = string.Empty; 
     dicParams["description"] = string.Empty; 
     dicParams["name"] = "deneme 123"; 
     dicParams["req_perms"] = "publish_stream"; 
     dicParams["scope"] = "publish_stream"; 
     dicParams["source"] = mediaObject; 
     dicParams["type"] = "normal"; 
     dicParams["access_token"] = srAcceToken; 
     var publishResponse = myClient.Post("/" + srPageId + "/photos", dicParams) 

위에 얻기를 위해 나는이 이미지를

enter image description here

코드 무엇입니까 코드 아래 사용하여 게시하지만 난 아래로 이미지를 게시 할 때 - 내가 그것을 어떻게 할 수 있습니까?

# 4.5하기 - 최신 페이스 북 SDK를 사용하여이

enter image description here

+0

어떻게 srPageId를 얻었습니까? 그 변수를 설정하는 코드는 없습니다 ... – theJerm

답변

5

희망을 주셔서 감사합니다이 짧은 코드는 ============== 당신에게

Dictionary<string,string> fbParams = new Dictionary<string,string>(); 
      fbParams["message"] = Title; 
      fbParams["caption"] = string.Empty; 
      fbParams["description"] = string.Empty; 
      fbParams["req_perms"] = "publish_stream"; 
      fbParams["scope"] = "publish_stream"; 
      //Initialize Your Facebook Client in the manner that suits you, I did it by supplying a saved access token from a single users 
      FacebookWebClient fbClient = new FacebookWebClient(<YOUR_ACCOUNT_ACCESS_TOKEN>); 
      //Get the listing of accounts associated with the user 
      dynamic fbAccounts = fbClient.Get("/me/accounts"); 

      //Loop over the accounts looking for the ID that matches your destination ID (Fan Page ID) 
      foreach (dynamic account in fbAccounts.data) { 
       if (account.id == <DESTINATION_ID_OF_YOUR_FAN_PAGE>) { 
        //When you find it, grab the associated access token and put it in the Dictionary to pass in the FB Post, then break out. 
        fbParams["access_token"] = account.access_token; 
        break; 
       } 
      } 
      //Then pass your destination ID and target along with FB Post info. You're Done. 
      dynamic publishedResponse = fbClient.Post("/" + <DESTINATION_ID_OF_YOUR_FAN_PAGE> + "/feed", fbParams); 

도움이 될 것입니다 =======================

fbParams [ "access_token"] = account.access_token;

이 줄을 통해이 페이지에 글을 쓸 수 있습니다.

관련 문제