ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 10th, 2012, 09:50 AM
id3ma id3ma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 114 id3ma Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 11 h 24 m 36 sec
Reputation Power: 0
Post to facebook graph with cfhttp

I have followed the tutorials/documentation on facebook's site and am one step away from publishing to a user's wall/timeline using coldfusion. I have one last step, post automatically with cfhttp. I can't get it to work.

Code:
<!--- 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="messages@mysite.com" to="messages@mysite.com" 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> 


The message returned from the fb_publish dump is:

{"error":{"message":"Invalid OAuth access token.","type":"OAuthException","code":190}}

I know the access token is accurate because I take the outputted code and paste it into the facebook debugger and it works just fine. The issue is with cfhttp post.

Reply With Quote
  #2  
Old April 10th, 2012, 08:50 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,091 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 2 h 53 m 27 sec
Reputation Power: 966
I would try to confirm that the request is correct by constructing a duplicate request in something like Poster.

Reply With Quote
  #3  
Old April 10th, 2012, 09:08 PM
id3ma id3ma is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 114 id3ma Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 11 h 24 m 36 sec
Reputation Power: 0
I went back into the graph documentation and noticed that the POST URL they display for JS SDK is different than what I had. So I changed the URL in the cfhttp post to match the POST format they display for JS. Then I pulled out all the form params except for the appId. Now it works.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Post to facebook graph with cfhttp

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap