Picture posting NOT working with facebook Graph API anymore - facebook

Picture posting NOT working with Facebook Graph API
The message is posted but the picture is NOT.
I am using the Graph API to post to the wall on Facebook.
My code was working fine posting the picture but is NOT posting picture anymore!
Here are the CURL parameters:
I am posting to URL: https://graph.facebook.com/ID/feed
and the POST parameters are:
access_token=TheToken&message=My+Message&picture=ImgUrl
where:
access_token is a valid access token
message is the message to display on the wall
picture is the image associated with the message to display on the wall
The ID is valid and access_token is valid.
Any help is appreciated, Facebook seems to be notorious in changing their API without informing interfacing sites!

I had the same problem when posting using the graph api via PHP. Dont know what the cause what, but my image URLs contained a - sign (http://the.url/to/the-image.jpg).
After renaming the images, everything worked as expected.
What is your image url?

I used the LINK parameter instead of the PICTURE parameter and all seems to be working now. Facebook changed something in regards to the PICTURE parameter where it stopped working. I did NOT change any code on my system and it just stopped working. See http://developers.facebook.com/docs/reference/api/post/

Ken, but what if you want link= to point to something else? this works:
curl -F \
"picture=http://tycho.usno.navy.mil/gif/moons/m146.gif" \
-F "message=you're looking great tonight!" \
-F "name=Current Moon Phase" \
-F "link=http://www.calculatorcat.com/moon_phases/phasenow.php" -F caption="How the moon appears tonight" \
-F "access_token=111111111111111|2222222222222222222222222|33333333333333333333456n" \
"https://graph.facebook.com/215958041750734/feed"
you can see result at: https://www.facebook.com/pages/The-Moon/215958041750734

works for me using source parameter:
$graph_url= "https://graph.facebook.com/me/feed?"
. "source=" . urlencode($_POST["picture"])
. "&link=" . urlencode($_POST["link"])
. "&message=" . urlencode($_POST['message'])
. "&method=POST"
. "&access_token=" .$access_token;
$response=file_get_contents($graph_url);
$json=json_decode($response);

Posting picture works for me but somehow including a source (swf) causes the picture to not display anymore. This used to work until last week.

Wait for it
I noticed that it takes more time for Facebook to process the picture (up to 15 minutes) than to post the link on the timeline (instant).

Related

I can't send a Facebook game request using Graph API v2.8

I've spent a lot of time trying to send a game request from the (latest) JS API, using the Graph API v2.8, but nothing seems to work.
I've used only common OG, since custom OG are deprecated. When I use "turn" instead of "send" as the action type, my request works, since the "turn" requests don't require an object id, so I guess the problem comes from my OG.
I first created an action like this:
curl -X POST \
-F "access_token=*a user access token*" \
-F "game=*my game id*" \
https://graph.facebook.com/v2.8/me/games.plays
And then sent a game request using it the returned id in the "object_id" field. And this is the result I got:
Facebook response after calling FB.ui
Which doesn't provide any information...
So I tried to make a game object instead of an action. I figured "maybe you can't use actions in this context", and since game.achievement is the ONLY game object available, I made an achievement object, like this:
curl -X POST \
-F "access_token=*my app access token*" \
-F "object={\"fb:app_id\":\"*my app id*\",\"og:type\":\"game.achievement\",\"og:url\":\"*object's URL*\",\"og:title\":\"*A title*\",\"og:description\":\"*A description*\",\"og:image\":\"*A link to an image*\",\"game:points\":\"1\"}" \
https://graph.facebook.com/v2.8/app/objects/game.achievement
This is the result that I got:
Facebook response after calling FB.ui
Which makes no sense, because the object was created using an app access token, and that my app IS a game. So this statement makes no sense.
And now, I'm lost. I have no solution left, no new idea to try. I don't know what to do... The documentation is obviously missing information. They didn't even bother making a documentation for the games.plays action...
I need someone who knows how to use this damned API to help me figure this out, because right now, I'm just completely stuck.
Thanks in advance, community.

Post Open Graph Action using the App Access Token

I am trying to post an action using Facebook Open Graph API based on the Facebook documentation. When I do the following :
curl -X POST \
"https://graph.facebook.com/app/myNamespace:myAction" \
-F "access_token=$APP_TOKEN" \
-F "myObject=https://myhost.com/objectid"
I get the following error :
{"error":{"message":"(#200) Requires extended permission: publish_actions","type":"OAuthException","code":200}}
I have obtained a valid 'App Token' using this Faceboo documentation. The document states that actions can be published using App Tokens.
Btw, I am able to successfully post actions using user-access-token as follows :
curl -X POST \
'https://graph.facebook.com/me/myNamespace:myAction' \
-F 'myObject=https://myhost.com/' \
-F 'access_token=user-access-token'
Any Help is greatly appreciated.
You're trying to post to an Open Graph action as the app, which is not possible.
Unfortunately, there is no documentation to that explictly says this, but here is someone who tried to do the same thing.
If you read the documentation you posted, you'll see two main points. First, app tokens are for publishing information on the feeds of user's who have given permission to the app to do so, and app tokens are for some other basic "maintenance" type stuff for the app itself. There is nothing in there that support the idea that app tokens can be used for anything like posting regular Open Graph actions.

How can I post in Facebook wall programmatically?

I'm very new to Facebook (yeah, I'm the only one) but I'd like to publish messages in the wall programmatically using Python.
What do I need to do to achieve that? I'm very confused. I have seen that most question about this are focused on how to let an app interact in some way with Facebook, but I'd like to post as if I were a simple user (a user which happens to "own" that particular Facebook page). Do I really need to go and create an app? (By the way, I'm having problems even with that... it tells me that my account seems fake or invalid even after I validated it via SMS). I imagine that there is a simpler way, introducing my credentials, using a POST request but I haven't read something similar.
I would have thought this is what I needed, but it leads to a page to create an app.
Some pointers?
By the way, I got a token via a publish_stream permission in the Graph API Explorer (using the extended permissions tab). Seems like this permission doesn't have expiration date but it's not recommended. Is there a better choice for a token?.
Thanks
Facebook is a bit trickier than other sites it would appear.
While watching the POST tab under NET in Firebug, while logging in, I see the following POST parameters:
charset_test €,´,€,´,水,Д,Є
default_persistent 1
email myusername
lgnjs 1340241652
lgnrnd 182050_CuPx
locale en_US
lsd AVqwALVx
pass mypassword
persistent 1
timezone 240
I don't yet know what lsd paramater is, but I did find out what the lgnrnd was by viewing the source of the login page before I logged in. It appears to be there to make it more difficult to automate authentication.
You first want your script to scrape that login page for that value, store it in a variable. Then, a cURL example would be something like:
curl -L "https://www.facebook.com/login.php?login_attempt=1" \
--cookie-jar /tmp/cookies.txt \
--data-urlencode "email=myusername" \
--data-urlencode "lgnrnd=$lgnrnd" \
--data-urlencode "pass=mypassword"
and so forth, with all the parameters...
This is untested of course, and I don't know what some of those parameter values are yet, but you should get the idea from that. You could probably use a python module like Beautiful Soup or something to apply the above basic concept.
Then you would do the same thing, watching the NET tab to find the parameters sent when you post to your facebook wall, and put it all together.
Note that I'm storing and using cookies with curl's --cookie-jar option. You will need a way to save and use cookies with the request as well, which is why I showed that.
Hope that helps you get started anyway..
What about this?.
import urllib2, urllib
parameters = {}
parameters['access_token'] = MY_TOKEN
parameters['message'] = 'Hello world'
target = 'https://graph.facebook.com/MY_ID/feed'
parameters = urllib.urlencode(parameters)
handler = urllib2.urlopen(target, parameters)
while True:
if handler.code < 400:
print handler.read() # Gets post_id
break
elif handler.code >= 400:
print 'Error' # :-(
break
Are there problems with this? Maybe a better way? Comments?
Thanks

Is there a trick to editing the status of an Ad Group?

According to the Facebook documentation, you can update the run status of an individual ad group via the ads api.
To do this, you submit a POST request to /<AD_GROUP_ID>/ with adgroup_status=X where X is your status (1 for active, 9 for paused, etc). However, making this request results in the status NOT changing, and the only response you get back from Facebook is a JSON representation of the Ad Group.
Has anyone been able to successfully submit ad group status updates to the facebook ads api? If so, are you using the method outlined above, or is there another trick to it?
thanks!
EDIT
I cross posted this into the Facebook Bug tracker in hopes to create a trail/awareness/find more people who were having this problem. https://developers.facebook.com/bugs/354657724569051
EDIT
An example of the request I'm making. This request is being tested from the Facebook Graph Explorer
https://graph.facebook.com/6003521999629?adgroup_status=9&method=POST&access_token=<access_token>
We have not been experiencing problems with changing adgroup_status. Try submitting the status number as an integer and then as a string (I don't remember which type they expect). Note that if the campaign is paused, setting the adgroup_status to 1 will actually change it to 8 (campaign_paused). The fact that you're getting the adgroup to redownload (I presume you have the redownload=1 parameter) tells me that your call is mostly correct. I just confirmed that this works:
curl -F "adgroup_status=9" \
-F "ids=..." \
-F "access_token=..." \
https://graph.facebook.com/
If you're making that API call and receiving the adgroup's details back instead of a 'true' response, it means you're making a GET request, not a POST request.
Update your code to make a HTTP POST request, and this will resolve your issue, John Pickard's answer above is an example of making a POST request in curl, but it will change depending on your application's language and/or which Facebook SDK you're using.

Open Graph custom action that links to other user

I have question about the beta Open Graph stuffs.
The documentation I am looking at is this https://developers.facebook.com/docs/beta/opengraph/
I successfully define custom objects and actions. However, I cannot figure out how to link current user with other users.
For example, say I define a custom action 'kick'. I want the current user to be able to 'kick' one of his/her friends.
The closest object I can think of is 'profile', but when I pass user_id, 'http://www.facebook.com/profile.php?id=', or http://graph.facebook.com/, it does not work.
This is the requests I tried
POST https://graph.facebook.com/me/myapp:kick?access_token=abc&profile=http%3A%2F%2Fwww.facebook.com%2F123
POST https://graph.facebook.com/me/myapp:kick?access_token=&profile=123
POST https://graph.facebook.com/me/myapp:kick?access_token=abc&profile=http%3A%2F%2Fwww.facebook.com%2Fprofile.php%3Fid%3D123
POST https://graph.facebook.com/me/myapp:kick?access_token=abc&profile=http%3A%2F%2Fgraph.facebook.com%2F123
This is the response I get
{"error":{"message":"An unexpected error has occurred. Please retry your request later.","type":"OAuthException"}}
The profile given is for an external website. They call it external profile. Pretty misleading terms.
As you can see I used the following
curl -F 'access_token=TOKEN' \
-F 'profile=http://graph.facebook.com/zuck' \
'https://graph.facebook.com/me/MYAPP:kick'
And it gave the above.
I guess you can fill the external profile with meta info from the Facebook users and it will show alright (for example I can send the profile URL facebook.com/zuck instead), but it seems backwards, inefficient and not the intended usage.
For example feeding it my link.
curl -F 'access_token=TOKEN' \
-F 'profile=http://facebook.com/username' \
'https://graph.facebook.com/me/MYAPP:kick'
But the thing is ... I am not a musician.
It does though seem to look alright in aggregation view.
Which is interesting/weird since one of objects shown in this picture is a Facebook profile, so you would think they would give an example with Facebook profiles as objects.
Though they did say
We are now extending the Open Graph to include arbitrary actions and objects created by 3rd party apps and enabling these apps to integrate deeply into the Facebook experience
Which most likely means they want you to create arbitrary objects outside of Facebook.
Can you still link to other users?
Yes, but through tagging using tags=FacebookID1,FacebookID2 but it will be in the form of
phwd kicked a musician with Friend1 and Friend2 on [APP NAME]