Facebook graph api Facebook发布到页面而不是用户墙
需要帮助发布到facebook的页面。我用了这篇文章 它是有效的。然而,我尝试发布的地方不是人墙,而是当用户登录到face book并单击右上角的齿轮符号时,它会显示“使用Facebook作为:ThingX”,然后他们选择ThingX。这将把他们带到ThingX页面,这就是我想发布到的地方。在代码中,如果我以个人身份登录,它将发布到他们的墙上,而不是ThingX。我如何发布到ThingX wall 我正在传递发布流,按照代码管理页面。。我不知道我是否需要在那里做些不同的事情 这是我现在使用的代码。。vb.netFacebook graph api Facebook发布到页面而不是用户墙,facebook-graph-api,Facebook Graph Api,需要帮助发布到facebook的页面。我用了这篇文章 它是有效的。然而,我尝试发布的地方不是人墙,而是当用户登录到face book并单击右上角的齿轮符号时,它会显示“使用Facebook作为:ThingX”,然后他们选择ThingX。这将把他们带到ThingX页面,这就是我想发布到的地方。在代码中,如果我以个人身份登录,它将发布到他们的墙上,而不是ThingX。我如何发布到ThingX wall 我正在传递发布流,按照代码管理页面。。我不知道我是否需要在那里做些不同的事情 这是我现在使用的代码
Dim app_id As String = "xxxxxxxxxxxx"
Dim app_secret As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Dim scope As String = "publish_stream,manage_pages"
If Request("code") Is Nothing Then
Response.Redirect(String.Format("https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}", app_id, Request.Url.AbsoluteUri, scope))
Else
Dim tokens As New Dictionary(Of String, String)()
Dim url As String = String.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}", app_id, Request.Url.AbsoluteUri, scope, Request("code").ToString(), app_secret)
Dim request__1 As HttpWebRequest = TryCast(WebRequest.Create(url), HttpWebRequest)
Using response__2 As HttpWebResponse = TryCast(request__1.GetResponse(), HttpWebResponse)
Dim reader As New StreamReader(response__2.GetResponseStream())
Dim vals As String = reader.ReadToEnd()
For Each token As String In vals.Split("&"c)
'meh.aspx?token1=steve&token2=jake&...
tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1))
Next
End Using
Dim access_token As String = tokens("access_token")
Dim client = New FacebookClient(access_token)
client.Post("/me/feed", New With { _
Key .message = "This is a test message -- " & Now.ToShortTimeString _
})
End If
我想知道是否有人能帮忙。
谢谢
香农
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~让它工作。。代码如下
好。。我终于让它工作了,在那里我可以发布到一个用户页面。赊欠在应得的地方赊欠。。给了我一部分时间。。然后,那个链接的作者好心地帮助我完成了剩下的工作。我使用Newtonsoft帮助我完成一些JSon工作。这是密码。。希望它能帮助别人。。再次感谢马克
脱机访问允许您创建不会过期的令牌
Dim app_id As String = "your app id"
Dim app_secret As String = "your app secret"
Dim scope As String = "publish_stream,manage_pages,offline_access"
If Request("code") Is Nothing Then
Response.Redirect(String.Format("https://graph.facebook.com/oauth/authorize?client_id={0}&redirect_uri={1}&scope={2}", app_id, Request.Url.AbsoluteUri, scope))
Else
Dim tokens As New Dictionary(Of String, String)()
Dim url As String = String.Format("https://graph.facebook.com/oauth/access_token?client_id={0}&redirect_uri={1}&scope={2}&code={3}&client_secret={4}", app_id, Request.Url.AbsoluteUri, scope, Request("code").ToString(), app_secret)
Dim request__1 As HttpWebRequest = TryCast(WebRequest.Create(url), HttpWebRequest)
Using response__2 As HttpWebResponse = TryCast(request__1.GetResponse(), HttpWebResponse)
Dim reader As New StreamReader(response__2.GetResponseStream())
Dim vals As String = reader.ReadToEnd()
For Each token As String In vals.Split("&"c)
tokens.Add(token.Substring(0, token.IndexOf("=")), token.Substring(token.IndexOf("=") + 1, token.Length - token.IndexOf("=") - 1))
Next
End Using
Try
Dim access_token As String = tokens("access_token")
Dim client = New FacebookClient(access_token)
' <-- put your USER access token here
Dim p As JsonObject = CType(client.[Get]("/me/accounts"), JsonObject)
Dim acc As jsondata = Newtonsoft.Json.JsonConvert.DeserializeObject(Of jsondata)(p.ToString)
Dim accData As New List(Of AccountData)
accData = acc.data
Dim mList = From w In accData _
Where w.ID = CStr("your id value that came back through JSON) _
Select w
Dim selected As New AccountData
For Each selected In mList.ToList
Next
Dim postparameters = New Dictionary(Of String, Object)()
postparameters("message") = Me.txtText.Text
Dim client1 = New FacebookClient(selected.access_token)
Dim result = DirectCast(client1.Post("/me/feed", postparameters), IDictionary(Of String, Object))
Dim postid = DirectCast(result("id"), String)
Return String.Empty
Catch ex As Exception
Return ex.Message.ToString
End Try
End If
嗯。。。您正在发布到“/me/feed”,它将发布到此人的feed。要发布到其他用户或页面的墙,您需要发布到页面id
引述:
You can publish to quite a few different kinds of objects via the Graph API:
Method Description Arguments
/PROFILE_ID/feed Publish a new post on the given profile's timeline. Note: requires publish permissions for the targeted profile. message, picture, link, name, caption, description, source, place, tags
/OBJECT_ID/comments Comment on the given object (if it has a /comments connection)
and so on..
嗯。。。您正在发布到“/me/feed”,它将发布到此人的feed。要发布到其他用户或页面的墙,您需要发布到页面id
引述:
You can publish to quite a few different kinds of objects via the Graph API:
Method Description Arguments
/PROFILE_ID/feed Publish a new post on the given profile's timeline. Note: requires publish permissions for the targeted profile. message, picture, link, name, caption, description, source, place, tags
/OBJECT_ID/comments Comment on the given object (if it has a /comments connection)
and so on..
对不起我的无知。。我用来指facebook的术语可能与我的想法相去甚远。我需要为ThingX页面创建应用程序吗。我试图从ThingX页面转到developer,但它希望我以登录用户的身份转到那里。。我想这是有道理的。。但我不确定是否需要在ThingX页面上创建应用程序。如果没有,你是说我可以使用我已经创建的应用程序并发布到ThingX页面吗。。但是我怎样才能找到ThingX的个人资料ID呢?再次感谢您的帮助。只需转到facebook页面,在其前面放一个“图表”,例如“代替”。您将在json对象中返回您的id。很抱歉我的无知。。我用来指facebook的术语可能与我的想法相去甚远。我需要为ThingX页面创建应用程序吗。我试图从ThingX页面转到developer,但它希望我以登录用户的身份转到那里。。我想这是有道理的。。但我不确定是否需要在ThingX页面上创建应用程序。如果没有,你是说我可以使用我已经创建的应用程序并发布到ThingX页面吗。。但是我怎样才能找到ThingX的个人资料ID呢?再次感谢您的帮助。只需转到facebook页面,在其前面放一个“图表”,例如“代替”。您将在json对象中返回您的id。