I am trying to publish stories from my server when people win a game into my web app.
I have folowed the documentation but i apparently do something wrong, here is the url and the datas object i pass into my POST call.
https://graph.facebook.com/'+user_id+'/points.win
var Datas = {
title: '500',
type: 'mygame:points',
image: 'http://mywebsite.jpg',
url: 'https://mywebsite.com',
description: 'YOU WIN !',
data: { rank: 326 },
'points': OBJECT_ID,
'access_token': TOKEN
};
I get the error: {"message":"Unknown path components: \/points.win","type":"OAuthException","code":2500}
I do have a "Points" object and a "Win" action on my app interface (and a "Win A Point" story).
I don't really know what i am doing wrong, also i am not sure my OBJECT_ID is right, i found a value close to my app_id at the end of the sample url by clicking "Get the Code" (on the points object) > Code for object > inside the object=...url=.../<here>... and i used it here but i didn't find where it's clearly said Object_id: <value> on developer.facebook.com.
UPDATE: I think the only way to get an object ID is to create it thought the Object API, i am going to try this way, i'll keep you updated if it's works or not.
I have created the object through the Object API and it works fine !
Related
Is it not possible to share multiple images through the Facebook share opengraph function?
The code snippet reads like this:-
FB.ui({
method: 'share_open_graph',
action_type: 'og.likes',
action_properties: JSON.stringify({
object: {
'og:url': xxx,
'og:title': xxxxx,
'og:description': xxxx,
'og:image': img_arr
}
})
}, function (response) {
// callback function goes here… });
It is required for img_arr to be an image array. But the dialog box shows up blank saying that “Sorry, something went wrong.
We're working on getting this fixed as soon as we can”. The images being shared on the facebook post is dynamic.
Facebook no longer allows the overrides. You must have the og metadata in the head.
I'm using Ember with ember-data and a rails api. I had a createRecord() and save() for the record that was working fine. The payload in the network tab for the post request to create the record in rails looks like: {data: {attributes: { foo: 'bar' } }.
In the rails controller, I have strong params like so: params.require(:data).require(:attributes).permit(:foo), which was working fine for a little while. Now when I send the request rails says that param is missing or the value is empty: data. If I look in the network tab in the browser the payload for the request still looks the same as stated above. If I puts params it only shows {"controller": "api/v1/answers", "action": "create"} and isn't showing the data payload at all.
Is there any reason why rails isn't picking up on the right params from ember now? I did try to add an association to the model that I'm trying to create, which is when it started failing. However, I rolled back to when it was working, but it's not working anymore.
I fixed this by going into the config/initializers/mime_types.rb file in the rails api and changing the file to look like:
api_mime_type = %W(
application/vnd.api+json
text/x-json
application/json
)
Mime::Type.unregister :json
Mime::Type.register 'application/json', :json, api_mime_type
So I am working on a Grails/Flex toy project. I have a controller(LoginController) that I am using to perform backend authentication on my Flex app. However, I have been unable to "find" my controller. What I mean by that is I get a HTTP Status 404 error when trying to access
http://localhost:8080/OrlandoGrails/LoginController/login.json
Here is my sad, sad little controller as it is in its proof-of-concept state.
package orlandograils
class LoginController {
static allowedMethods = [login: "POST", login: "GET"]
def login(String username, String password )
{
return "Hello"
}
}
I've seen the documentation concerning RESTful services, but they always seem to concern a domain object which I don't have. In any case, I have also added this to my UrlMappings.groovy file
"/LoginController/login.json"(resource:"LoginController")
Any help on what I'm doing horribly wrong would be greatly appreciated. Also, is there a way to list Grails routes like one can with RoR or Symfony2?
Also, while the bulk of my services will be over the amf channels, my authentication is occurring over http.
It isn't entirely clear what you are trying to accomplish but one problem with your sample is that in your URL mapping you are specifying the name of a controller as your resource, which doesn't make sense. That could be a domain class, but not a controller.
If all you want to do is map a url to particular action in the controller you can do something like this in UrlMappings.groovy...
"/LoginController/login.json"(controller: 'login', action: 'login')
Normally you wouldn't have "Controller" in the url so something like this would be more common...
"/login/login.json"(controller: 'login', action: 'login')
From the little code snippet it also isn't clear what role you want JSON to play. Maybe you just want something like this...
"/login"(controller: 'login', action: 'login')
If you can further describe what you are trying to accomplish I can clarify.
In regards to getting a listing of routes (e.g. URL Mappings) you can run grails url-mappings-report
Also note to modify url-mapping to look like:
"/LoginController/login.json"(controller: "login", action: "login")
If resource is used then default action methods has to be show, create, update and delete
//Using resource: would look for a show() action method for a GET
//request which you don't have in your case. And, note name of controller used
//is login instead of LoginController
"/LoginController/login.json"(resource: "login")
As far as the 404 is concerned it's looking for a corresponding view called "hello.gsp" If you want to render text then use:
render text: 'hello'
The original post includes this:
package orlandograils
class LoginController {
static allowedMethods = [login: "POST", login: "GET"]
def login(String username, String password )
{
return "Hello"
}
}
The allowedMethods property there is bogus. Keys in a Map have to be unique. That code attempts to put the key login in the Map twice. If the intent is to say that the login method may be accessed via POST or GET then this makes sense...
static allowedMethods = [login: ['POST', 'GET']]
The code as written is valid, but it doesn't do what it was probably intended to do. That Map will evaluate to only have 1 value associated with the login key. That doesn't have anything to do with Grails, that is just standard Map behavior.
$ groovysh
Groovy Shell (2.1.9, JVM: 1.7.0_45)
Type 'help' or '\h' for help.
-------------------------------------------------------------------------------
groovy:000> [login: 'GET', login: 'POST']
===> {login=POST}
groovy:000>
Notice that the expression evaluates to a Map with the value "POST" associated with the login key.
When I call myModel.save(), in one of my controllers, to insert a new record into the store I get back a promise with isRejected: true.
The reason object has the following attributes:
readyState: 4,
status: 201,
statusText: "created"
The object is created properly in my backend REST service. In fact, if I put the transitionToRoute in the catch(), instead of the then(), everything would appear to be just fine.
What's going on here?
You need to return the object back with your request. This is particularly important because the server should provide an id for that newly created record. Without an id there is no definitive way of updating and being sure you're updating the correct record. The format should follow the same format if you were to find the model.
IE:
{
type: {
id:12312,
property:'value',
otherProperty:'value'
}
}
As of today, almost all of my app's calls to share links on user's feeds are failing with the following error:
{
"message": "(#1500) The url you supplied is invalid",
"type": "OAuthException",
"code": 1500
}
Uisng PHP cURL, I'm posting to https://graph.facebook.com/{user_id}/feed and submitting a link parameter pointing to a valid, working URL (plus message params) etc.
Strangely, I can issue a command line cURL request and the request seems to work correctly (at least I haven't had an error yet).
I don't want to file a bug report yet incase I've missed something in a breaking migration. Any ideas as to what may be causing this?
http://developers.facebook.com/bugs/476666205677592
I have this problem too. it happened randomly. I'm sure the url I supplied is valid and can not reproduce it. So reported bug here..
Erro While FB Publish: {contents = "(#1500) The url you supplied is invalid"}
Solution:
1. Go to: https://www.facebook.com/
2. Click on Setting > manage app
3. Select "Edit App" button
4. Select "Permission" under the "Setting" panel at left side
5. Make Auth Token Parameter: To "URI Fragment(#access_token=…)"
6. Click "Save Changes" button.
Its fixed now!!!
The solution for me was:
1) I uploaded photo to my facebook user account
$fb->setFileUploadSupport(true);
$fb->setAccessToken('access token of my user (just to post an image)');
var_dump($fb->api('/me/photos', 'POST', ['image' =>'#F:\\fb\\fb_2.jpg','msg' =>'sss']));
2) After that set access for this picture to "For everyone" on my facebook page.
3) Then took var_dumped id to url https://www.facebook.com/photo.php?fbid={var_dumped id}
4) For every user, authorized my app, the following code started work normally $fb->api('/' . $fbuserid . '/feed', 'POST', [ 'link' => 'https://www.facebook.com/photo.php?fbid={var_dumped id}', 'message' => 'my post', 'type'=>'photo']);