Open Graph & Rails not retrieving object's URL - facebook

I'm using Rails to try and add an action for an object both defined for my app on the open graph. I am using an :after_filter in my controller to call the following after session#create:
#graph.put_connections('me', 'workkout:complete', :session => url_for([#plan, #session]))
I am getting the following back from Facebook:
{"error":{"type":"Exception","message":"Could not retrieve data from URL.","code":1660002}}
I have checked that the correct URL is passed to put_connections, and when I visit this URL using Facebook's Lint tool, everything is correct.
I can't understand why this isn't working, my only thought is that Facebook is hitting the URL moments before rails has generated the object? - not sure if that's even possible though.
Can anyone shed any light on this?

Turns out it was because the create action and the put_connection methods take place in independent threads and as such the URL is not ready when put_connections is called. Solution here http://railscasts.com/episodes/363-facebook-open-graph?autoplay=true

Related

Can't display Facebook user avatar with Facebook API and Graph

I'm working in a React-Native app, and I'm also allowing users to login using FBSDK.
There seems to be an issue at the moment when trying to get the profile picture URL.
There are also several reports of this, like this one but still, after a year doesn't seem to be solved.
Attempted many ways but none worked, it always tries to download the file, seems it's missing the mime-type according to what the browser says.
The URL it gives is the following:
https://platform-lookaside.fbsbx.com/platform/profilepic/?asid={{myfbid}}&height=50&width=50&ext=1583348357&hash=AeTnFpMVwBXgFy_J
Also tried using the graph url directly: http://graph.facebook.com/{myid}/picture
And if I add the &redirect=false, it returns a data object with the platform-lookaside URL.
Everything I try, it tries to download.
This is how I'm currently trying to get the image using Graph API.
new GraphRequestManager().addRequest(new GraphRequest(
'/me',
{
accessToken: fbToken,
parameters: {
fields: {
string: 'picture.type(large)'
}
}
},
graphRequestCallback
)).start();
It works, but the URL is the same.
Any idea on how can I solve this? I might be missing something or the bug is still happening?
If you just change the graph url (http://graph.facebook.com/{myid}/picture) from http to https, it should work for you. Not sure if that's a new fix in React Native or not, but that solved it for me.

Facebook auth serverside calls back 2 times with the same code

On our server-side authentication with Facebook we get a random and weird issue. Facebook calls the call back URL two times with the same code. This is only happening for some users and not on every login.
This is the flow we have implemented on our side: https://developers.facebook.com/…/manually-build-a-login-fl… . We have been using it since the beginning of 2013 and we haven't noticed any issues so far.
And this is the error we get when we are exchanging the code for an access token the second time.
{"error":{"message":"This authorization code has been used.","type":"OAuthException","code":100,"fbtrace_id":"traceID"}}
We tried to log this issue as a bug on https://developers.facebook.com/bugs but unfortunately it doesn't work.
It keeps showing unexpected error. Not to mention that i was unable to find the correct bug category.
Any idea on how we can fix this?
Thanks!
Could it be that users are clicking twice to process auth service? Try disabling the button before calling Facebook auth service
What language are you using?
I just had this problem in Ruby using Devise for Rails. I had created an omniauth.rb initializer file, and added a config line item in the devise.rb initializer file.
If you did this too, you can remove the omniauth.rb initializer file and you should be good to go!

Publishing a story using Facebook open graph

I am currently trying to run through the publish open graph story for iOS tutorial on the Facebook website.
https://developers.facebook.com/docs/tutorials/ios-sdk-tutorial/publish-open-graph-story/
I'm getting lost at step 2 - Set up your back end server. I have set up a Heroku account just like it says and I go through the set up tutorial on the Heroku site. It all seems fine. I save the code listed in step 2 in a new file I created called opengraphobject.php (I have no idea if this was the right thing to do?).
After that it says "Once you've uploaded the dynamic object creation code, test a sample object using the Object Debugger. Enter a URL into the debugger, for example:"
https://fbsdkog.herokuapp.com/repeater.php?fb:app_id=233936543368280
&og:type=fb_sample_scrumps:meal
&og:title=Pizza
&og:description="Pizza"
&og:image=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fimages%2Fdevsite%2Fattachment_blank.png
&body=Pizza
I have no idea what I'm supposed to do at this point. My action is called beats and the object is called boss. How do I generate a url like this for my own action?
I can't move onto stop 3 till I move past this because it's very similar.
The page opengraphobject.php should contain the sample code provided in that step.
So when you are done setting it up you point to your url in the debugger to test
https://YOUR.herokuapp.com/opengraphobject.php?fb:app_id=YOUR_APP_ID
&og:type=fb_sample_scrumps:meal
&og:title=Pizza
&og:description="Pizza"
&og:image=https%3A%2F%2Fs-static.ak.fbcdn.net%2Fimages%2Fdevsite%2Fattachment_blank.png
&body=Pizza

ref=ts on facebook app url cause app not found error

I've create an facebook app and it run smoothly at
https://apps.facebook.com/icoloringstar/
But the problem is: when I search my app name "icoloring star" in facebook, it link to the app at url:
https://apps.facebook.com/icoloringstar/?fb_source=search&ref=ts
Then facebook said that:
App "iColoring Star" is unavailable
The app "iColoring Star" is temporarily unavailable due to an issue with its third-party developer. We are investigating the situation and apologize for any inconvenience.
We found that url part "ref=ts" cause above problem, but really do not know why?
Could you explain me why and how to resolve this problem?
Thank you very much.
It sounds like your code is failing when the ref parameter is supplied in the request path.
I was able to repro this with any arbitrary value in the ref parameter when accessing your app
Check your server logs and and see if you're returning a 500 error to facebook when the request comes in
See if you have any code that parses a ref parameter and check it's not throwing exceptions
Make sure your callback URL in the app settings doesn't also specify a ref parameter or your app may receive two values and/or fail entirely
It means 'Top Search'. User enter a query into the top of search.
There are some ref parameters.. ref=bookmarks for example. I dont know the full list.
Did you put your app on Facebook App Center?

Codeigniter Facebook app POST method AND query_string

I have a toy facebook app I'm playing with so I can understand how it all works. It's fine if you go the the app like this: http://apps.facebook.com/pushup-challenge/ (and connect it). But if you then go to it from your facebook page, FB uses the URL http://apps.facebook.com/pushup-challenge/?ref=bookmarks.
In my log file, I see that FB is POSTing the data and including the /?ref=bookmarks to it's call to my codeigniter system. This is causing it to either say "invalid URI parameters" or give me a 404, depending on if I've edited the system/core/URI.php file to add rawurlencode() to a particular call.
I've tried using mod_rewrite to get rid of the query_string, too, but since it's POSTing, it doesn't appear to be working (though I'm not exactly sure why).
Has anyone else run into this? How did you fix it?
Thanks in advance,
Hans
try $config['uri_protocol'] = “PATH_INFO”; and set enable_query_strings = TRUE
or
set
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?=';
in config.php
Because it isn't calling your file by name (just ?ref=bookmarks) the server runs thru the standard default files: index.htm, index.html, index.asp. Because you need to accept a POST, you need a server that allows POSTs to htm & html if you choose to use those. Index.asp will accept POSTs on most servers, and that works for me.
SOLUTION: Add a file (index.asp), that calls the real app that you named in the App settings.