I am trying to post to a Facebook feed with a message, image (URL), and a link using CFHTTP. I can't figure out from FB documentation how to do the image and URL. I can post the message just fine but when I try an image and link it doesn't work.
<cfhttp method="post" url="https://graph.facebook.com/v4.0/#facebookSettingsPageID#/feed" result="facebookResponse" charset="utf-8">
<cfhttpparam name="access_token" type="formfield" value="#facebookPageToken#">
<cfhttpparam name="message" type="formfield" value="#form.message#">
<cfhttpparam name="picture" type="FORMFIELD" value="#form.pic#">
<cfhttpparam name="link" type="FORMFIELD" value="#form.urlLink#">
</cfhttp>
"Can you provide us the complete url of the image you're trying to upload.
For domain verification follow the steps provided in the link below.
https://developers.facebook.com/docs/sharing/domain-verification"
Related
Anyone have any experience with the EZ Text API and ColdFusion? I'm trying this call:
<cfhttp url="https://app.eztexting.com/sending/messages?format=JSON"
method="POST" result="objGet" charset="utf-8">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
<cfhttpparam type="formfield" name="User" value="xxx" />
<cfhttpparam type="formfield" name="Password" value="xxx"/>
<cfhttpparam type="formfield" name="PhoneNumbers[]" value="9999999999" />
<cfhttpparam type="formfield" name="MessageTypeID" value="1" />
<cfhttpparam type="formfield" name="Message" value="Hello" />
</cfhttp>
... which is returning a status code of 200 and trying to redirect to their home page.
Their tech support can only tell me that I should use curl which is not installed on the server that I need it on. I have used curl successfully in my devel environment, so I'm sure that the url and credentials are good.
Any thoughts are welcome! Thanks.
I'm guessing you're using the REST API. If yes, the reason it's redirecting you to the home page is because the URL is incorrect. Apparently the format parameter is case sensitive. So ?format=JSON should be changed to ?format=json (all lower case).
Making that minor adjustment to your code example:
<cfhttp url="https://app.eztexting.com/sending/messages?format=json"
method="POST" result="objGet" charset="utf-8">
...
</cfhttp>
... returns the expected JSON response for bogus credentials, instead of the html for the home page:
{
"Response": {
"Status": "Failure",
"Code": 401,
"Errors": [
"Authorization Required"
]
}
}
Once you get past this issue, you may want to double check your formfield names. The API lists the parameter name PhoneNumbers, not PhoneNumbers[].
I started to work on Google Drive API with ColdFusion and I am stuck to upload the file using ColdFusion. I have done with the registration of new project, getting client and client secret and I am successfully able to get the accessToken but somehow I am not able to upload the file on the google drive.
Here is the code to get the code and accesstoken
<cfoutput>
<cfset request.oauthSettings = {
scope = "https://www.googleapis.com/auth/drive", client_id = "clientid",
client_secret = "clientsecret",
redirect_uri = "link"}
/>
<!--- create login url --->
<cfset loginURL = "https://accounts.google.com/o/oauth2/auth?scope="
& request.oauthSettings["scope"]
& "&redirect_uri=" & request.oauthSettings["redirect_uri"]
& "&response_type=code&client_id=" & request.oauthSettings["client_id"]
& "&access_type=offline"
/>
Login with Google account that has access to analytics
<cfif isDefined("URL.code") AND URL.code NEQ "access_denied">
<cfhttp url="#arguments.gaOauthUrl#" method="post">
<cfhttpparam name="code" type="formField" value="#arguments.code#">
<cfhttpparam name="client_id" type="formField" value="clientid">
<cfhttpparam name="client_secret" type="formField" value="clientsecret">
<cfhttpparam name="redirect_uri" type="formField" value="link">
<cfhttpparam name="grant_type" type="formField" value="authorization_code">
</cfhttp>
</cfif>
</cfoutput>
I am using the following code to upload the file, I know I have to pass some more parameters to make it correct but I don't know what are that parameters.
<cfhttp url="https://www.googleapis.com/upload/drive/v2/files?uploadType=media" method="post">
<cfhttpparam name="Content-Type" type="formField" value="text/plain">
<cfhttpparam name="Authorization" type="formField" value="#session.ga_accessToken#">
</cfhttp>
I am trying to find out in the google docs but no luck; there is no documentation for ColdFusion. Please let me know the other parameters if someone has some clue about this area.
You aren't setting the Authorization header correctly. It should be
Authorization: Bearer ya29.AHES6ZRosLBEnyGGH9EysIrAB7Z
I am trying to solve a problem that occurs with Authorize.net. The SessionToken is generated while in test mode through a test account. Now, a new SessionToken is generated each time the form is previewed through the test account or the actual account.
A hidden input field is shown each time when the form is accessed in preview mode. I have generated a hidden input field on my form by using a toBase64() string combined from the x_login and the x_tran_key. The output is this:
<INPUT TYPE="HIDDEN" NAME="SessionToken" ID="SessionToken" VALUE="TXpOSFRUWXpXbk40VjNSeg==TlRsU2JqaHFOM2RLZFd0RU5VdzJadz09">
in the forms hidden input field for SessionToken as you can see above.
When generating my own SessionToken for processing, the error shown after trying to process the https://test.authorize.net/gateway/transact.dll shows this:
(46) Your session has expired or does not exist. You must log in again
to continue working.
The only way for the form to actually work is after grabbing the SessionToken code from the form in preview mode. For example: Go to Account --> Settings --> Payment Form --> Preview --> and viewing and copying the code from view frame source. It looks like this:
<INPUT TYPE="HIDDEN" NAME="SessionToken" ID="SessionToken" VALUE="jMsCez2DId$VvgF4s4Hbjbe$Uv6WnJh8cEKBD5HqTUEqlHoRBebKZ07bp4RZdpwOPnGabB3pbcWFppJCph7dg6HjQeroJvlay6mQm5ocjkZPq44uT4nqeg2zWhX13b7Blp$qN7ZDzQ5HF1abfukJTQAA,jMsCez2DId$VvgF4s4Hbjbe$Uv6WnJh8cEKBD5HqTUEqlHoRBebKZ07bp4RZdpwOPnGabB3pbcWFppJCph7dg6HjQeroJvlay6mQm5ocjkZPq44uT4nqeg2zWhX13b7Blp$qN7ZDzQ5HF1abfukJTQAA">
Finally, if I use the value:
jMsCez2DId$VvgF4s4Hbjbe$Uv6WnJh8cEKBD5HqTUEqlHoRBebKZ07bp4RZdpwOPnGabB3pbcWFppJCph7dg6HjQeroJvlay6mQm5ocjkZPq44uT4nqeg2zWhX13b7Blp$qN7ZDzQ5HF1abfukJTQAA
as the SessionToken as:
<cfset SessionToken = 'jMsCez2DId$VvgF4s4Hbjbe$Uv6WnJh8cEKBD5HqTUEqlHoRBebKZ07bp4RZdpwOPnGabB3pbcWFppJCph7dg6HjQeroJvlay6mQm5ocjkZPq44uT4nqeg2zWhX13b7Blp$qN7ZDzQ5HF1abfukJTQAA'>
and process the form it works. But it only works one time for the current session if signed into the Test Account.
All help is appreciated of course. This is the last part to the code I need and just can not figure out how to make it work. I need to fetch the response for the SessionToken to populate the SessionToken hidden field input on the form.
I am not using the CFHTTP method because the form is on the website and when the payment form loads the SessionToken is needed. Meaning that the submit/sending... button on the form is submitted it then processes the payment and displays the receipt.
If you download the Coldfusion sample code from Authorize.net you will notice you do not need a SessionToken. See below:
Source: http://developer.authorize.net/downloads/samplecode/
<cfhttp method="Post" url="https://test.authorize.net/gateway/transact.dll">
<!--- the API Login ID and Transaction Key must be replaced with valid values --->
<cfhttpparam type="Formfield" name="x_login" value="API_LOGIN_ID">
<cfhttpparam type="Formfield" name="x_tran_key" value="TRANSACTION_KEY">
<cfhttpparam type="Formfield" name="x_delim_data" value="TRUE">
<cfhttpparam type="Formfield" name="x_delim_char" value="|">
<cfhttpparam type="Formfield" name="x_relay_response" value="FALSE">
<cfhttpparam type="Formfield" name="x_type" value="AUTH_CAPTURE">
<cfhttpparam type="Formfield" name="x_method" value="CC">
<cfhttpparam type="Formfield" name="x_card_num" value="4111111111111111">
<cfhttpparam type="Formfield" name="x_exp_date" value="0115">
<cfhttpparam type="Formfield" name="x_amount" value="19.99">
<cfhttpparam type="Formfield" name="x_description" value="Sample Transaction">
<cfhttpparam type="Formfield" name="x_first_name" value="John">
<cfhttpparam type="Formfield" name="x_last_name" value="Doe">
<cfhttpparam type="Formfield" name="x_address" value="1234 Street">
<cfhttpparam type="Formfield" name="x_state" value="WA">
<cfhttpparam type="Formfield" name="x_zip" value="98004">
<!--- Additional fields can be added here as outlined in the AIM integration
guide at: http://developer.authorize.net --->
<!--- The following fields show an example of how to include line item details, they are commented out by default.
<cfhttpparam type="Formfield" name="x_line_item" value="item1<|>golf balls<|><|>2<|>18.95<|>Y">
<cfhttpparam type="Formfield" name="x_line_item" value="item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>Y">
<cfhttpparam type="Formfield" name="x_line_item" value="item3<|>book<|>Golf for Dummies<|>1<|>21.99<|>Y">
--->
</cfhttp>
Hope this helps.
I am having troubles figuring out the google api.. I am trying to insert data into my fusion table via my coldfusion application..
<cfhttp url="https://www.google.com/accounts/ClientLogin" method="post" charset="utf-8">
<cfhttpparam type="formfield" name="accountType" value="GOOGLE"></cfhttpparam>
<cfhttpparam type="formfield" name="Email" value="MYUSERNAME"></cfhttpparam>
<cfhttpparam type="formfield" name="Passwd" value="MY PASSWORD"></cfhttpparam>
<cfhttpparam type="formfield" name="accountType" value="GOOGLE"></cfhttpparam>
<cfhttpparam type="formfield" name="service" value="fusiontables"></cfhttpparam>
</cfhttp>
this comes back with
SID=DQAAALoAAAC5eSJUrVB_WVchS1plunfW2YPUTadHAxoEbE0xMcOzQxeTloc2RWWBjoJi4jKm6NIiFbGbV_IQ3vuY9bl-Z0RS64OFAy5aUY-Do_nX8DpPhVkEyBzDScJidi73G7ZqWmkdykkIGCBrr7MLa-eBMrXZvLJP0D21xJTjxRWyeM4xuEMQGhEbnWwBL9RnEByr5Rsgzx7dl9n4tsYQOvaGV3ZcMlT0CooS2__orwC12UH7eKCk-REKzbX5Z-bbu4EdLps LSID=DQAAALwAAABV7lz-YRh02pR7IlWkKidScbYTQArBWnaAJpAlZQ9rgtgmdQCSBuIZQQ21QDXZLORwTAyDi-34Mjs8SKvI7ronBSuniDW2SGipYoUhZDEjxwR55DQc1AaI3JgGPMc69YGAVv-_EMwXlS7elWO6lDW-G4PTR6Aqa0DO3y7Iig-L7g2b7zMFq32JIvjUj5rofcykF27T8sOuhd0Z4XTvgO-18Kp2z8o6EK_5qjZcHPmih0GB6LeSElBo2wjah1TM2u0 Auth=DQAAALwAAADYQbciaOLab2Aw_QghTO8hR0DPDOjoWZVKeJ-ApGwoUz7OgcqVtSHMUvRHHZoKys5ygjhm2FiHSh1CvW1SicOvajwRZSstvghtsCQl-y7LeT8TMkeCj5ZIqy8A05wg1YjCz3F3eDz9TImtlvGij7IOdWJ3Ae4NE8WQdC0Js5Laccebhgjj7Lk9FkRgG9c3yRyGhu7LmsRbtLjfv5jwGoozDuCcx6b79bECoR8qABkT-e5HgF7sWjYbLfz667OCeA0
Now I am trying to insert into my table... I am passing the auth value from above.. I can not find anywhere in the google docs what the authentication fields should be.. any help would be greatly appreciated..
<cfhttp url="https://www.google.com/fusiontables/api/query" method="post" charset="utf-8">
<cfhttpparam type="formfield" name="sql" value="INSERT INTO 423555 (id, outcode,lat,lng) VALUES ('1','W14',1231232,-123123);"/>
<cfhttpparam type="header" name="Authorization" value="Auth"></cfhttpparam>
<cfhttpparam type="header" name="token" value="#listtoarray(cfhttp.FileContent,"=")[4]#"></cfhttpparam>
</cfhttp>
The AUTH should be the auth token you received in google's response.
From the docs you should make a header like:
Authorization: GoogleLogin auth=yourAuthToken
So, this would be
<cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#listtoarray(cfhttp.FileContent,"=")[4]#"></cfhttpparam>
This is assuming the #listtoarray(cfhttp.FileContent,"=")[4]# returns the value of the Auth property - I haven't counted it out to be sure.
I don't think, just glancing at the docs, the "token" header is needed.
But, #listtoarray(cfhttp.FileContent,"=")[4]# is a really fragile way of doing it. If Google were to reorder their response or change it, your code wouldn't work any more.
I would look to a more robust way of parsing the response. I would probably split the response on whitespace and turn it into a struct with the names as keys, then you could use something like
#response['auth']#
Greetings.
I'm trying to send a quick sms through google voice using their existing API. I think the api is what's left from the Grand Central days. They don't have much documentation. Here's where I got my documentation: http://posttopic.com/topic/google-voice-add-on-development
I can authenticate using cfhttp and get the correct response. Then I can get the "_rnr_se" value that is required for request from a google voice command.
When I send over the number, message, and required values (Authorization and _rnr_se), I get a "content-length" is required message from google. But since this is a dynamic post with different form fields, not a file, I'm not sure what to post as the content-length.
If I just put some arbitrary value like "1000" for the content-length, the request just sits there and I never get a response. If I put something like "0" or "500" it comes back with a 500 - "Internal Server Error".
Any ideas on how to get the correct value for content-length before I post?
<cffunction name="submitSMS">
<cfhttp url="https://www.google.com/voice/sms/send/" method="post">
<cfhttpparam type="header" name="Content-Length" value="???">
<cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#SESSION.GoogleAuth#">
<cfhttpparam name="id" value="" type="formfield">
<cfhttpparam name="phoneNumber" value="+1#params.number#" type="formfield">
<cfhttpparam name="text" value="#params.smsMessage#" type="formfield">
<cfhttpparam name="_rnr_se" value="#SESSION.rnr#" type="formfield">
</cfhttp>
<cfdump var="#cfhttp.FileContent#"><cfabort>
</cffunction>
The better way to do this is to just use the google voice java class here:
http://google-voice-java.googlecode.com