I'm playing with the facebook graph api, and was attempting to send an image to my wall. According to facebook, you just send the image, your access key & a caption... see below my code:
<cfoutput>
<cfif fileexists("D:\myPath\images\menubar.jpg")>
<cfhttp method="post" url="https://graph.facebook.com/me/photos" multipart="yes">
<cfhttpparam type="formfield" name="access_token" value="myAccessToken">
<cfhttpparam type="file" name="source" file="D:\myPath\images\menubar.jpg">
<cfhttpparam type="formfield" name="message" value="this is a test picture.">
</cfhttp>
<cfdump var="#cfhttp#">
</cfif>
</cfoutput>
When I run this, I get a 400 bad request error ("OauthException an unknown error occurred" returns from facebook). Does anyone know what I'm doing wrong? Thanks!
can you check your access token format?
usually parameters set as access_token=somedata&expires=sometimestamp
At the statement you mentioned above, you have to pass just access token literally. I make it bold here. access_token=somedata&expires=sometimestamp
I've been trying to solve the same problem nearly for 3 hours. :) and finally did!
I've run into issues using https when the secure certificate hasn't been imported into the Java/ColdFusion keystore. More info on how to achieve that here:
http://kb2.adobe.com/cps/400/kb400977.html
Hope that helps!
Related
I'm trying to use the facebook graph api to update the message on a previous post. I have the original post id and a valid never ending user access token. I am getting a "success" message back, but the post message is NOT getting updated.
<CFHTTP METHOD="POST" URL="https://graph.facebook.com/v3.2/#qPost.PostID#?message=#URLEncodedFormat(Message)#&access_token=#AccessToken#" THROWONERROR="YES">
<cfhttpparam type="header" name="Accept-Encoding" value="*" />
<cfhttpparam type="header" name="TE" value="deflate;q=0" />
</CFHTTP>
Success Message:
I'm going off the facebook graph details here (i know it says publish_actions permission has been removed), but certainly there has to be a way to update a page post via the graph api.
https://developers.facebook.com/docs/graph-api/reference/v3.2/post#updating
Also when I say I'm trying to update the message, basically the text that is written in the post (see image)
I got this figured out, i was not using the full postid in my request. When the original post was created it sends back a post id, which is a combination of the pageid and the postid (with an underscore in between), it looks like this below, with the first part being the pageid and the one after the underscore being the postid, I was only putting the 2nd part as the postid:
334797943936653_2003899366299670
It's funny that i would still get a "success" even though I had an invalid postid.
The documentation example states
POST /v3.2/post-id HTTP/1.1
Host: graph.facebook.com
message=This+is+a+test+message
So message is part of the POST body. But your code sends the message as part of the query string. Solution: Move message and access_token to the body.
<cfhttp method="POST" url="https://graph.facebook.com/v3.2/#qPost.PostID#" throwOnError="true">
<cfhttpparam type="header" name="Accept-Encoding" value="*" />
<cfhttpparam type="header" name="TE" value="deflate;q=0" />
<cfhttpparam type="formfield" name="message" value="#Message#" />
<cfhttpparam type="formfield" name="access_token" value="#AccessToken#" />
</cfhttp>
Encoding is done by cfhttpparam automatically, so keep the readable/desired text in the message variable.
I want to do a facebook post from my coldfusion application to a test page. I have created a test page and I am the admin of that page. Now I got the API key and Page ID with the given details. The issue is when I post the request to facebook using
<cfhttp url="https://graph.facebook.com/v2.2/#MyPageID#/feed" result="access" >
<cfhttpparam type="formfield" name="access_token" value="#MyAccessToken#" />
<cfhttpparam type="formfield" name="message" value="#MyMessage#" />
</cfhttp>
I am getting all the posts from my page and the message is not posted. Can anyone help? Please let me know if you need any more help.
Oh. It is just a simple mistake and it made me to hang for hours. After wasting much hours, I have found that the HTTP call method must be post.
<cfhttp url="https://graph.facebook.com/v2.2/#MyPageID#/feed" result="access" method="false">
<cfhttpparam type="formfield" name="access_token" value="#MyAccessToken#" />
<cfhttpparam type="formfield" name="message" value="#MyMessage#" />
</cfhttp>
So the final lesson is, when the method is get, it reads the posts and when it is post, it adds a new post.
i first tried to make request to server with GET method and it works fine. my request would process a file then return as a pdf file and would open on a new browser. what i did is overriding the doGet() method. since having a GET request is only limited to few parameters, i must change it to doPost() mehod but the problem is that it can't be overrided because the method is final.
in an HTML FORM, what i wanted to happen is something like this:
<form method="post" action="http://differentdomain.com/appserv/appserv.php">
<input type="hidden" name="fwi_script" value="app/custom/cusapp/interface" />
<input type="hidden" name="trx" value="<trx>
<productid>PROD1</productid>
....../** transaction details here */
</trx>" />
<input type="hidden" name="fcompanyid" value="SHOST101" />
<input type="hidden" name="fwi_action" value="PRINT_PENDING_SALES" />
<input type="hidden" name="fexcel" value="0" />
<input type="submit" value="Submit" />
</form>
this html form will print the order slip of every transaction when user clicks on the post order button.
anyone can give an idea on how to POST request in GWT server? i think i can't do it with RequestBuilder since i will be having the SOP problem since i will be connecting to a different domain.
To build very nearly the same html you have in your question, start with a FormPanel and add the form fields you need to it. Make sure to configure the FormPanel with the correct action and method, and to provide names (and possibly values) to the fields added to it. To fire off the request, submit() can be called.
The solution is to make a normal GWT RPC call to your server and have the server make the POST request to the server located on a different domain.
I'm trying to post feeds to the personal facebook wall and the fan page wall from my site for a logged in user.
<cfhttp url="https://graph.facebook.com/me/feed" method="post">
<cfhttpparam name="access_token" value="#variables.accessToken#" type="formfield">
<cfhttpparam name="message" value="#arguments.message#" type="formfield">
<cfhttpparam name="link" value="#arguments.link#" type="formfield">
<cfhttpparam name="name" value="#arguments.name#" type="formfield">
<cfhttpparam name="caption" value="#arguments.caption#" type="formfield">
<cfhttpparam name="description" value="#arguments.description#" type="formfield">
<cfhttpparam name="picture" value="#arguments.picturePath#" type="formfield">
</cfhttp>
This is as per the code from developers.facebook.com and a sample from http://net.tutsplus.com/tutorials/php/wrangling-with-the-facebook-graph-api/
This is just a sample of what I think the parameters mean:
But when it posts to the wall, the following happens:
The message, picture, name, caption and description appear properly
But the link does not, the picture points to itself and the link on the name points to the picture.
After referring to numerous posts, I thought I'd post this.
Please help.
You should give the protocol as well.
So try this:
http://www.traffikworks.com/community.html
(I put the www, becuase you redirect the browser anyway with 301)
Facebook currently uses HTTPS whenever your password is sent to us
So when I go to http://www.facebook.com and click login, they have sent my username and password through https even though I am not on a https connection yet.
Does anyone know how this works?
The form's action is https://www.facebook.com/login.php?login_attempt=1. The page with the login form doesn't need to be https, as it is just used to craft a request to the https page.
Also, since http is stateless, you're not really "on" a connection until the moment you send a request. After you get a response, and the page draws, you are no longer "on" the connection.
When you are creating a form just post it to a https page.
<html>
<body>
<form action="https://mypage.com" method="POST">
<input type="text" name="mytext" />
<input type="submit />
</form>
</body>
</html>
This should work even though you are not a https secured page.