How to post a link with a picture to Facebook using the Graph API? - facebook

I have tried two different methods.
The first is to specify the link in the /PROFILE_ID/feed link argument (as described under "publishing" here). The problem is that if I specify anything other than my application URL i get an error saying the URL is invalid.
The second is to use the /PROFILE_ID/links method and specifying a picture URL. The problem is that when it posts it only shows the message and the URL. I've specified values for picture, name and message but none of them show.
How can I Post a link, with a name, message and picture?

Your first approach is the correct one. Is your url starting with http://? What SDK are you using?
As described on this page, the example suggest it should work.
http://developers.facebook.com/docs/reference/api/post
curl -F 'access_token=...' \
-F 'message=Check out this funny article' \
-F 'link=http://www.example.com/article.html' \
-F 'picture=http://www.example.com/article-thumbnail.jpg' \
-F 'name=Article Title' \
-F 'caption=Caption for the link' \
-F 'description=Longer description of the link' \
-F 'actions={"name": "View on Zombo", "link": "http://www.zombo.com"}' \
-F 'privacy={"value": "ALL_FRIENDS"}' \
-F 'targeting= {"countries":"US","regions":"6,53","locales":"6"}' \
https://graph.facebook.com/me/feed

I ended up solving this problem by using the /PROFILE_ID/feed method and then disabling Stream post URL security in my application security settings. Hope this helps someone!

Related

Creation of Paypal encrypted button returns the error 11945 invalid country and locale combination

I am implementing the creation of encrypted Paypal buttons using their Button Manager API. Despite all my efforts I am facing the error 11945 The button country and language code combination specified is invalid..
First I tried to implement the creation of my own button but while tracing this error, I ended up with their tutorial using curl, which fails for me too with the same error. (Note: I had to change the credentials to mine).
To be specific, this code from their tutorial fails with the error 11945:
curl https://api-3t.sandbox.paypal.com/nvp \
-s \
--insecure \
-d USER=<my-user-name> \
-d PWD=<my-password> \
-d SIGNATURE=<my-signature> \
-d VERSION=51.0 \
-d METHOD=BMCreateButton \
-d BUTTONCODE=ENCRYPTED \
-d BUTTONTYPE=CART \
-d BUTTONSUBTYPE=PRODUCTS \
-d BUTTONCOUNTRY=US \
-d L_BUTTONVAR1=item_name%3Dshoehorn \
-d L_BUTTONVAR2=amount%3D1464.46 \
-d L_BUTTONVAR3=tax=%3D21 \
-d L_BUTTONVAR4=item_number%3D123456
I tried to figure out why is that but I haven't found any relevant sources.
Can anyone explain this issue? The country code is set to US, which should be fine.
All help will be appreciated.
Note: I am using the sandbox right now.
Note: Defining locale through lc attribute does not help. I tried en as well as en_US values.
After a discussion with the Paypal support, there is the conclusion.
Short version: It's a bug.
Long version (by moderator MTS_Ciaran):
Thanks, so this looks like a bug on the sandbox from what I can see.
The issue is that the account is CZ and for some reason we're not
allowing the button creation because of that. It doesnt look to be the
same on the live environment so I would suggest using a US account for
testing and once live the CZ account shouldn't be an issue.
I'll
work internally to get the sandbox corrected for this.

Facebook Video Page Post with Call to Action

I want to post a video to facebook with call to action button but it seems the video was successfully posted on facebook page but call to action button was ignored. Anyone has any idea what could the problem please?
curl -F 'name=My Video' \
-F 'description=This is my first video' \
-F 'source=#myvideo.mp4' \
-F 'published=1' \
-F 'call_to_action={"type":"LEARN_MORE","value":{"link":"<LINK>","link_format":"VIDEO_LPP"}}' \
-F 'access_token=<PAGE_ACCESS_TOKEN>' https://graph-video.facebook.com/v2.8/<PAGE_ID>/videos

Post to a Facebook user's wall with curl PERL

I'm storing facebook userid's and access tokens. Can I post to a selected user's wall with this information? The following code is found at Facebook's developer reference.
I'm just not sure how to run it with Perl.
curl -F 'access_token=$accessToken' \
-F 'message=Check out this funny article' \
-F 'link=http://www.example.com/article.html' \
https://graph.facebook.com/$facebookid/feed
or this code:
curl -F 'access_token=$accessToken' \
-F 'photo=http://samples.ogp.me/$appID' \
'https://graph.facebook.com/me/$appNameSpace:$objectType'
Why not use the Facebook::Graph module to do what you need? It's a rich wrapper around the facebook API.
You need to perform a HTTP POST request with these form data, see method post in LWP::UserAgent.

Graph API bug - posting links, missing description

When posting a link on a page using the Graph API, the description is missing.
Might be related to this bug http://bugs.developers.facebook.net/show_bug.cgi?id=14782.
Is this going to be fixed? Now I'm posting as feed/ instead, here the description is shown - but then there is no "share" button.
Any known workaround?
I'm not sure why this is, and really it doesn't make much intuitive sense, but I've had success posting to the PAGE_ID/links feed, rather than identifying the page ID independently and then just posting to graph.facebook.com/links
Thus, I'm posting using:
curl -F 'access_token=ACCESS_TOKEN' \
-F 'link=LINK' \
-F 'name=TITLE' \
-F 'description=DESCRIPTION' \
https://graph.facebook.com/PAGE_ID/links
Rather than:
curl -F 'access_token=ACCESS_TOKEN' \
-F 'link=LINK' \
-F 'name=TITLE' \
-F 'description=DESCRIPTION' \
-F 'id=PAGE_ID' \
https://graph.facebook.com/links
In my testing, the former allows proper formatting of each of the elements, while the latter does not. Both surface the share link. I do not know why this is, but it works.
Hope this helps.

Facebook Application: Uploading multiple images in one post to wall

How to upload multiple images in one post via api?
Like here:
http://www.facebook.com/SocialCity?v=wall
I have managed to upload only one image via curl request.
curl
-F "access_token=token_here"
-F "message=message_here"
-F "picture=http://www.example.com/image.jpg"
https://graph.facebook.com/app_id_here/feed
Or it's not possible to post multiple images this way?
Anyone?
Thanks ;)
It's possible by now with the Open Graph however it seems to apply only to user generated fotos:
https://developers.facebook.com/docs/opengraph/usergeneratedphotos/
Multiple photo upload via one Graph API call is not supported. However you can create individual api calls and batch those in one request described here: https://developers.facebook.com/docs/reference/api/batch/
You can now publish multiple images in a single post to your feed or page:
For each photo in the story, upload it unpublished using the {user-id}/photos endpoint with the argument published=false
curl -i -X POST \
-d "url=https%3A%2F%2Fwww.facebook.com%2Fimages%2Ffb_icon_325x325.png" \
-d "caption=test%20photo%20upload" \
-d "published=false" \
-d "access_token=<user_photos_token>" \
"https://graph.facebook.com/v2.6/me/photos"
You'll get an ID for each photo you upload like this:
{
"id": "10153677042736789"
}
Publish a multi-photo story using the {user-id}/feed endpoint and using the ids returned by uploading a photo
curl -i -X POST \
-d "message=Testing%20multi-photo%20post!" \
-d "attached_media%5B0%5D=%7B%22media_fbid%22%3A%221002088839996%22%7D" \
-d "attached_media%5B1%5D=%7B%22media_fbid%22%3A%221002088840149%22%7D" \
-d "access_token=<publish_actions_token>" \
"https://graph.facebook.com/v2.6/me/feed"
Source: Publishing a multi-photo story