Как использовать cfhttp для автоматической публикации в API-интерфейсе facebook?

Я следил за учебными пособиями/документацией на сайте facebook и нахожусь в одном шаге от публикации на стене/временной шкале пользователя с помощью coldfusion. У меня есть последний шаг, опубликовать автоматически с помощью cfhttp. Я не могу заставить его работать.

<!--- This is the page that you call and also use as the redirect_uri... facebook returns code and state in the URL --->
<cfparam name="URL.code" default="" type="string">
<cfparam name="URL.state" default="" type="string">
<cfif #URL.code# EQ "">
    <cfparam name="URL.error_reason" default="" type="string">
    <cfparam name="URL.error" default="" type="string">
    <cfparam name="URL.error_description" default="" type="string">
    <cfmail charset="utf-8" type="html" server="mail.mysite.com" from="[email protected]" to="[email protected]" subject="Facebook Authentication Denial">
    #SESSION.my_profile_id#: #SESSION.my_profile_username#
    #URL.error_reason#<br/>
    #URL.error#<br/>
    #URL.error_description#<br/>
    </cfmail>
    <cfabort>
<cfelse>
    <cfhttp 
    method="get"
    url="https://graph.facebook.com/oauth/access_token?client_id=myappid&redirect_uri=http://www.mysite.com/dbf/_my-controller/fb_user_code.cfm&client_secret=216792f1a1ddbb568c57624a988028dc&code=#Trim(URL.code)#"
    result="my_fb_user_token"/>
    <cfif #my_fb_user_token.filecontent# CONTAINS "access_token=">
        <cfset new_token = ReplaceNoCase(#my_fb_user_token.filecontent#,"&expires","|","all")>
        <cfset new_token = REReplaceNoCase(#new_token#,"\|.*$","")>
        <cfquery name="fb_confusion" datasource="#dsn#" maxrows="1">
        SELECT facebook_id
        FROM my_profile
        WHERE my_profile_id = '#SESSION.my_profile_id#'
        </cfquery>
        <cfoutput>#new_token#</cfoutput>
        <hr/>
        <cfhttp 
        method="get"
        url="https://graph.facebook.com/me?#new_token#"
        result="my_fb_user"/>
        <cfoutput>https://graph.facebook.com/#fb_confusion.facebook_id#/feed?#new_token#</cfoutput>
        <hr/>
        <cfoutput>
        <cfhttp url="https://graph.facebook.com/me/mysite:add?group=http://www.mysite.com/dbf/test_group.cfm&#new_token#"
        result="fb_publish" 
        method="post" 
        multipart="yes">
            <cfhttpparam name="appID" value="myappid" encoded="no" type="url">
            <cfhttpparam name="access_token" value="#my_fb_user_token.filecontent#" encoded="no" type="url">
            <cfhttpparam name="message" value="Test" encoded="no" type="url">
            <cfhttpparam name="link" value="http://www.mysite.com" encoded="no" type="url">
            <cfhttpparam name="name" value="Test" encoded="no" type="url">
            <cfhttpparam name="caption" value="Testing fb api" encoded="no" type="url">
            <cfhttpparam name="description" value="Testing to see if this posts" encoded="no" type="url">
        </cfhttp>
        </cfoutput>
        <cfdump var="#fb_publish.filecontent#">
    </cfif>
</cfif>

Сообщение, возвращенное из дампа fb_publish:

{"error":{"message":"Неверный токен доступа OAuth.","type":"OAuthException","code":190}}


person Community    schedule 10.04.2012    source источник
comment
Ваш токен доступа действителен? Вы получили токен через соответствующий процесс oAuth?   -  person Jason    schedule 10.04.2012
comment
Да. Токен действителен. Я вывожу его в приведенном выше коде, копирую его, когда он возвращается, и вставляю его в отладчик графов facebook, и он отлично работает. Проблема начинается с cfhttp method=post   -  person    schedule 10.04.2012
comment
Я не могу ответить до 8 часов... мля. Прежде всего, URL-адрес в сообщении cfhttp необходимо изменить на тот, который Facebook имеет в качестве URL-адреса сообщения в руководстве: graph.facebook.com/me/ Затем нужно было изменить мои параметры с type=url на type=formfield. Вот и все. Теперь это работает.   -  person    schedule 10.04.2012
comment
Злость. Как раз тогда, когда я думал, что закончил... Теперь я получаю новую ошибку. Этому действию не разрешено устанавливать пользовательское сообщение, поскольку это свойство не было запрошено на утверждение ???   -  person    schedule 10.04.2012


Ответы (1)


Попробуйте https://github.com/affinitiz/facebook-cf-sdk.

или попробуйте альтернативный метод (грязный метод, используемый мной :))

http://cfmitrah.com/blog/post.cfm/update-facebook-status-using-email-without-graph-api

person JS Mitrah    schedule 13.04.2012