Facebook Credits Invalid State Transition Error - facebook

I am using Github sample code for the Facebook Credits (callback.php and index.php) but its giving me the below error.. anybody have any solution???
"Order::update_order called with invalid state transition:3 -> 0"
Thanks..

Hard to answer without seeing the code you're using, but the response you send should look like this:
{
"method": "payments_status_update",
"content": {
"order_id": ORDER_ID,
"status": "settled"
}
}
ORDER_ID should be replaced by the order id sent from fB with the request.
There were incorrect examples out there that showed:
{
"method": "payments_status_update",
"content": [{
"order_id": ORDER_ID,
"status": "settled"
}]
}
but the second one doesn't work. Check to make sure you're not sending content as an array.

Related

SuiteCrm Rest API: JSON Body attributes throws error when calling POST or PUT

I'm using postman in order to call SuiteCRM REST API.
I tried to call this endpoint
PATCH http://{{suitecrm-url}}/Api/V8/module
and i've added this payload to the body (Content-Type: Application/Json):
{
"data": {
"type": "Accounts",
"id": "3a3ae651-d509-2508-7dc4-5be2e51cc96b",
"attributes": {
"name": "name with space"
}
}
}
When the request is executed SuiteCRM gives this response:
{
"errors": {
"status": 400,
"title": null,
"detail": "The option \"attributes\" with value array is invalid."
}
}
I found out that the problem was the whitespace in the value: when i tried to use the value "namewithspace", it worked.
Anyone has any idea how to solve this problem ?
Thanks in advance
I found out this issue on github that resolved my problem:
https://github.com/salesagility/SuiteCRM/issues/6452
In short to make it work i had to modify the file in
/Api/V8/Params/Options/Fields.php
and replace this line
const REGEX_FIELD_PATTERN = '/[^\w-,]/';
with
const REGEX_FIELD_PATTERN = '/[^\w-,\s\]/';
The person mentioned in github:
this is just for temporary fix and not upgrade safe

Echonest track profile requests always return an empty audio_summary

I'm requesting bucket=audio_summary for songs that rank highly in hotttness.
The top 100 hotttessst songs all return track.status: 'complete' but the audio summary is always an empty object.
How do I get audio summary data like time_signature and tempo? Doesn't track.status: complete imply that this information should be included in the response?
Can't Feel My Face
https://developer.echonest.com/api/v4/track/profile?api_key=*****************&format=json&id=SOMVZDS14DDE5909E7&bucket=audio_summary
{
"response": {
"status": {
"version": "4.2",
"code": 0,
"message": "Success"
},
"track": {
"status": "complete",
"id": "SOZOIDR14C02B654D4",
"audio_summary": {}
}
}
}
It looks like you have the SongId rather than the TrackId for this song. If you replace 'track' with 'song' in your query you get the expected results.
This:
https://developer.echonest.com/api/v4/song/profile?api_key=*****************&format=json&id=SOMVZDS14DDE5909E7&bucket=audio_summary
Returns this:
{
"response":{
"status":{
"version":"4.2",
"code":0,
"message":"Success"
},
"songs":[
{
"artist_id":"ARYUDWF12F2B89BB33",
"artist_name":"The Weeknd",
"id":"SOMVZDS14DDE5909E7",
"audio_summary":{
"key":9,
"analysis_url":"http://echonest-analysis.s3.amazonaws.com/TR/A7NwGAWSmhnc53M8w1rLk-eA_tsN8OUHaqV5C5FTbb9BnCPZVnxWOGld1wLxJJ-xdNV8xKJbbZlCRSKJc%3D/3/full.json?AWSAccessKeyId=AKIAJRDFEY23UEVW42BQ&Expires=1454028841&Signature=HeUxbEJt4f0ncipjD1Gamtuj08E%3D",
"energy":0.781735,
"liveness":0.12022,
"tempo":107.954,
"speechiness":0.042317,
"acousticness":0.124391,
"instrumentalness":0.0,
"mode":0,
"time_signature":4,
"duration":216.46667,
"loudness":-5.528,
"audio_md5":"",
"valence":0.586261,
"danceability":0.713659
},
"title":"Can't Feel My Face"
}
]
}
}
The only reason I was able to track this down was that throwing any ID into the track API give back the stub response you were seeing and I was able to get the audio_summary for this song using the spotify id so I knew it was available.

How should we retrieve an individual post now that /[post-id] is deprecated in v2.4?

I just tried through the Graph API Explorer with this path /v2.4/10153513872748291 and I've got this result:
{
"error": {
"message": "(#12) singular links API is deprecated for versions v2.4 and higher",
"type": "OAuthException",
"code": 12
}
}
But https://developers.facebook.com/docs/reference/api/post/ doesn't say anything about deprecation.
I'm not sure if I miss something, or there's another way to get info about an individual post.
Edit: v2.3 works, but v2.4 is the latest one.
Looks like you now need to the combination of the id of the user or page that made the post (or whose wall it is on), an underscore, and then the post id.
For your example post, 10153513872748291, that is made by a page Drama-addict, that has the id 141108613290 – so 141108613290_10153513872748291 will work.
And so does 788239567865981_10153513872748291, because 788239567865981 is the id of the user making the post.
Firstput userId underscore add postId /Likes to check Like status in facebook
userId_post_Id/Likes to fetch Likes Records
userId_post_Id/Comments to fetch Comments Records
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=303261006522998_751199848395776%2FLikes&version=v2.9
**In this link Right side Get Token indide GetAccessToken to select Permission**
303261006522998_751199848395776/Likes
303261006522998_751199848395776/Comments
{
"data": [
{
"id": "124778301449917",
"name": "Manisha Gera"
},
{
"id": "1680577265523548",
"name": "Rubi Sharma"
}
],
"paging": {
"cursors": {
"before": "MTI0Nzc4MzAxNDQ5OTE3",
"after": "MTY4MDU3NzI2NTUyMzU0OAZDZD"
}
}
}

Getting attachments from Facebook conversations

I currently use the Facebook Graph API to get a inbox conversation. Most of the messages look like this:
{
"id": "1452301718360191_1407164668",
"from": {
"id": "10203840837848742",
"name": "Øyvind Knobloch-Bråthen"
},
"message": "Some message",
"created_time": "2014-08-04T15:04:28+0000"
}
However, some of the messages in the conversation are images, and they are represented like this:
{
"id": "1452301718360191_1407164668",
"from": {
"id": "10203840837848742",
"name": "Øyvind Knobloch-Bråthen"
},
"created_time": "2014-08-04T15:04:28+0000"
}
So basically what is different is that the message is gone. But since there is no mention of the attachment, or url to the image or anything else I can use, I'm not able to display the image in my app.
So my question is: How can I get a hold of the image (or url to the image). Hopefully it will be available in some way when I have the message ID.
With Graph api V2 the egde to retrieve inbox messages is /id/conversations
id is eitheir a user id or a page id
Each conversation message with attachment should return an "attachments" field.
Then for each message with attachment you should query the url https://api.facebook.com/method/messaging.getattachment?mid=message_id&access_tokes=your_access_token
Note that it does not work with graph api v2.1. Unless you curl the query

facebook graph can not get comments

After Search post from graph
https://graph.facebook.com/search?q=watermelon&type=post&fields=from,message,picture,link,name,caption,comments,description,created_time,id&token=XXXXXXXXXXXXX
here will return some data. In the third post:
"from": {
"name": "Alessio Mrbillyplus Frustaci",
"id": "1665626783"
},
"picture": "http://external.ak.fbcdn.net/safe_image.php?d=AQDGoBK_lUeeMb5x&w=130&h=130&url=http\u00253A\u00252F\u00252Fi3.ytimg.com\u00252Fvi\u00252Fjo5GcYeh7XA\u00252Fdefault.jpg",
"link": "http://www.youtube.com/watch?v=jo5GcYeh7XA&feature=share",
"name": "Herbie Hancock \"Watermelon Man\"",
"caption": "www.youtube.com",
"description": "From the 1973 album \"Headhunters\" here's Herbie Hancock with \"Watermelon Man\" Sampled by Super Cat \" Dolly My Baby\" LL Cool J \"1-900-LL Cool J\" Shaquille O'N...",
"created_time": "2011-09-17T17:44:48+0000",
"id": "1665626783_235117223205324",
"comments": {
"data": [
{
"id": "1665626783_235117223205324_3043725",
"from": {
"name": "Alessio Mrbillyplus Frustaci",
"id": "1665626783"
},
"message": "La enne e la doppia effe aaaaaa",
"created_time": "2011-09-17T17:45:52+0000"
}
]
}
},
It is clearly that it has comments in it. So the PostID is 1665626783_235117223205324 and CommentID is 1665626783_235117223205324_3043725? But when I tried search a post or comments, the data return empty.
https://graph.facebook.com/1665626783_235117223205324?access_token=XXXXXXXXXXX//empty
https://graph.facebook.com/1665626783_235117223205324/comments?access_token=XXXXXXXXXXX//empty
https://api.facebook.com/method/fql.query?
callback=json&
query=SELECT%20comments%20FROM%20stream%20WHERE%20post_id%20%3D%20'1665626783_235117223205324'&access_token=XXXXXXXXXXXXXX //empty
What is the big problem?
There may be privacy settings in place which prevent the current user from seeing the posts or comments, where are those comments posted? Are you accessing them with an access_token from a user who can see the content?
As Mahima said, both of those calls should be working and i've tested equivalent calls with posts from my own news feed or page walls.
A call to /1665626783_235117223205324 for me returns false, which indicates i don't have permission to view the item.
This could also be a bug, but you'd need to have a very clear set of sample data to demonstrate the issue so it can be reproduced by Facebook
I tried with post id and comment id both as
http://graph.facebook.com/COMMENT_OR_POST_ID?access_token=APPLICATION_ACCESS_TOKEN
both are working ..
Make sure the access_token you are using is either of the application which you used for posting on a user's wal.. Or the access_token has sufficient read_stream and offline_access permission of the user ..