Trying to figure out the correct Json string to pass to my OpenGraph app. I'm using the Gigya Java SDK, but decided to eliminate some of the extra layers in testing the string.
So I'm first of all looking at the Graph API Explorer.
My POST field name is "Recipe" and the value is
{"title":"one-handed fried pies","description":"ye olde Description goeth here.","image":"http://www.recipe.com/images/one-handed-fried-pies-R094255-ss.jpg","url":"http://www.recipe.com/one-handed-fried-pies/"}
This maps exactly to the fields of the Recipe object.
However, no matter how I format the JSON, I get this exception
{
"error": {
"message": "(#3503) \"{\"title\":\"one-handed fried pies\",\"description\":\"ye olde Description goeth here.\",\"image\":\"http://www.recipe.com/images/one-handed-fried-pies-R094255-ss.jpg\",\"url\":\"http://www.recipe.com/one-handed-fried-pies/\"}\" is an invalid value for property \"recipe\" with type \"Reference\"",
"type": "OAuthException",
"code": 3503
}
}
Any thoughts?
By hacking thru, got it to work this way.
Most important... the URL as above must point to a page that has valid og: tags for the app. (You can look at the source of this page for the structure http://www.csmonitor.com/Science)
In the Graph Api Explorer,Select your Application in the top left.
Click get Access token.
Select POST.
Click on Add a field
Type the name of the object. In my case "recipe".
Type the url. In my case, I set up a live test page and deployed it.
click submit and wait for an id.
{
"id": "290473937742173"
}
Related
Seeing release 1.3.3 of the smartsheet SDK and the ability to import XLS files straight from the SDK (which I haven't tried yet), I started thinking about how I would be able to achieve my goal to upload very large sheets with a minimum number of requests.
(see related questions: Building whole sheet programmatically with Python SDK, How to create a project sheet via the python SDK)
My current test methodology is to import an XLS file (though the UI so far), which comes in not formatted properly (Trying to make a project sheet, with gantt view, and resource management).
Using the python SDK, I use the Sheets.copy_rows() method to copy the rows from the sheet that was imported in the UI, to another blank sheet that is created following my project sheet template.
This seems to work perfectly, with the exception of the contact column, in which I would like to display the contact name rather than the contact email address.
According to https://smartsheet-platform.github.io/api-docs/?python#contact-list-columns:
When creating or updating cells for a contact list column, the
displayValue attribute works as follows:
If displayValue is non-null and non-empty, the Smartsheet cell displays the value provided.
If displayValue is an empty string, the Smartsheet cell displays the email address.
If displayValue is null or absent, Smartsheet makes a best guess effort at filling it in with a contact’s name based on the email
address.
Looking at the sheet I created from the import, I can see my cell data as: {"columnId": 7027801426552708, "value": "eleroy#******.com"}.
According to the doc above, since displayValue is absent, I was hoping the copy into a contact list column would attempt to fill with the contact's name based on the email address.
Is there a way I can force it to convert to the contact's name either on XLS import or during the copy?
Edit:
As seen with some of the answers below, I guess it makes sense that the copy would copy the data as is, so I'm left trying to have it fill in the contact name on XLS import.
I am trying to find a way to inject both the display value and the value in Excel, but haven't succeeded yet. I have tried Hyperlinks, email links, =HYPERLINK() formula, but so far no success.
If you set the Value with the email address and the displayValue as the contact name, you should be able to get what you're looking for. For example, the following body of a generic HTTP request would display "MyUser Gmail" in the cell, but have the myuser#gmail as the contact email.
[
{
"toBottom": true,
"cells": [
{
"columnId": 6xxxxxxxxxxxxxx8,
"value": "myuser#gmail.com",
"displayValue": "MyUser Gmail"
}
]
}
]
If the displayValue is empty, it's an indication that this cell's Contact does not have a name associated with it. If your original sheet does include a name, the point of failure is likely in the copy process.
Without looking into the Python SDK, I might guess that copy_rows() is only copying by value and not displayValue. Try manually setting the value/displayValue of the contact cell and see if that works.
I'm reading the user/notifications facebook stream (https://developers.facebook.com/docs/graph-api/reference/v2.4/notification/).
As part of the result i'm getting an Object.
"The object (this can be a post, a photo, a comment, etc.) that was the subject of the notification."
Is there a way to identify if the object is post or comment or like etc'?
Thanks,
fredy
You can retrieve the type of a Facebook Object if you using something Facebook call "Introspection" by adding metadata argument to your request:
GET http://graph.facebook.com/object_id?metadata=1
The resulting JSON will include a metadata property that lists all the supported edges for the given node and a type field
Find more on : https://developers.facebook.com/docs/graph-api/using-graph-api/v2.4 under the section Introspection.
I'm trying to post a custom story to a proof of concept Facebook app, consisting of an object type "badge" and an action type "earn." When I "get code" for this in the Facebook Open Graph Types interface, the Graph Explorer example successfully posts the story to my timeline. However, the one parameter ("badge") is a URL reference to OG samples.
How can I post something directly, not as a reference to OG samples?
Using the C# SDK, I'm currently trying this:
var client = new FacebookClient();
client.AccessToken = tokenResult.access_token;
dynamic parameters = new ExpandoObject();
parameters.badge = #"
{
""app_id"" : [my app ID],
""title"" : ""Widget Badge"",
""image"" : ""[a public image URL]"",
""url"" : ""[a public website URL]"",
""type"" : ""[my custom namespace]:badge""
}
";
var result = client.Post("/me/[my custom namespace]:earn", parameters);
However, the exception I'm getting back from Facebook is:
"[the above JSON]" is an invalid value for property "badge" with type "Reference"
Following some code snippets I've found online, I tried changing the property "badge" above to a generic "post" (I would guess relying on the "type" value to know what it's posting), but then the error says that I'm missing the required parameter "badge."
I haven't found anything which tells me what a "Reference" type is in this case, though I could just be overlooking something. In the original example it was a URL to OG Samples, but I would assume we can post custom things and not just samples. Do I need to host some sort of "sample" page of my own with the values in meta tags like OG Samples, or can I just specify the values directly in the post somehow?
To post actions with an object, you need to provide the url of this object.
But in the case where you don't have this url on your own app (you app doesn't have a webpage for each object), then you can create objects hosted directly by facebook, and the url will use the generated id of this object.
To do that, you need to use the Object API : https://developers.facebook.com/docs/opengraph/using-object-api/
Providing the json data, it will create the object in facebook opengraph, returning its id (so you have the url) and then you'll be able to post your action
I'm developing an Android App that uses the Places API to retrieve information and displays it on a map. The initial request to retrieve to places fails with a ACCESS_DENIED status message from the HTTP request. Below is the code that I used to generate the request:
try {
HttpRequestFactory httpRequestFactory = createRequestFactory(HTTP_TRANSPORT);
HttpRequest request = httpRequestFactory
.buildGetRequest(new GenericUrl(PLACES_SEARCH_URL));
request.getUrl().put("key", API_KEY);
request.getUrl().put("location", _latitude + "," + _longitude);
request.getUrl().put("radius", _radius); // in meters
request.getUrl().put("sensor", "false");
if(types != null)
request.getUrl().put("types", types);
PlacesList list = request.execute().parseAs(PlacesList.class);
// Check log cat for places response status
Log.d("Places Status", "" + list.status);
return list;
In another Stackoverflow posting someone had suggested that the poster try the following to test their key:
Go to the api console here, then to SERVICES. Click Active services
tab and verify 'Places API' is turned ON. Click on the ? "try" link
next to it. It should create a proper URL with your key which should
work. Compare the link that you are trying against this URL for
differences.
I followed these instructions. Based on the fact that I received the following results when I clicked on the ? to "try" the link I suspect something is fundamentally wrong with the API Key independent of the code...otherwise I would think I would get a SUCCESS rather than REQUEST_DENIED:
{
"html_attributions" : [],
"results" : [],
"status" : "REQUEST_DENIED"
}
I obtained my key by entering the SHA1 of my debug certificate (which i obtained using Keytool with all the appropriate parameters...e.g, androiddebugkey....debug.keystore) followed by a ";" and the Package Name of the app.
Not sure what the problem is...I'm sure it's something simple but I'm not seeing it and I'm stuck. Thoughts?
I never received a response to this posting so ultimately I've resolved the problem by creating a brand new key under a new project name and I was at least able to retrieve Places from Google..I'm still having issues with populating maps but that could be a code issue.
I noticed that the key that I was using that gave me the ACCESS DENIED results had a title of: "Key for Android apps (with certificates)" and it had a label "Android apps:" listed just under the actual key. The key value is the SHA1 value ";" followed by the Package Name. Whereas the key I created under a new Project Name (Places API) that ultimately worked had a title of: "Key for browser apps (with referers)" and it had a label of "Referers:" and value of "Any referer allowed".
So there is definitely something different about these two keys. I'm not sure what I did differently when I generated the keys. I'd like to understand what I did to generate these two "different" types of keys so that I and perhaps others won't repeat my "mistake(s)".
There are many references to creating keys in the Google documentation. The fact that there are so many postings regarding problems with the keys tells me that the Google documentation is not very clear otherwise so many issues wouldn't exist on this topic.
Starting last month, it appears that community pages either require a user access token to access the graph image, or will not allow application to access the image.
As an example: The community page for Harold and Maude (105636526135846), last month would return a picture -- now calls to the graph do not include the picture string.
{
"id": "105636526135846",
"name": "Harold and Maude",
"link": "http://www.facebook.com/pages/Harold-and-Maude/105636526135846",
"likes": 143886,
"category": "Movie",
"is_community_page": true,
...
At one point it appeared that using an access token would work, however, now requesting '/105636526135846/picture' returns no picture and Facebook's embedded image is
http://external.ak.fbcdn.net/safe_image.php?d=AQBKNDbD3RCI0MXv&w=180&h=540&url=http%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fen%2Fc%2Fc4%2FHarold_and_maude.jpg&fallback=hub_movie
Alternatively FQL appears to return the proper information
>[
>> {
>>> "pic": "http://external.ak.fbcdn.net/safe_image.php?d=AQA4PX9DD7wlHZmC&w=100&h=300&url=http%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fen%2Fc%2Fc4%2FHarold_and_maude.jpg&fallback=hub_movie",<br />
>>> "pic_large": "http://external.ak.fbcdn.net/safe_image.php?d=AQBKNDbD3RCI0MXv&w=180&h=540&url=http%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fen%2Fc%2Fc4%2FHarold_and_maude.jpg&fallback=hub_movie"<br />
>> }<br />
>]
Is there something I'm missing with the graph? I'm concerned that the FQL method may stop working.
Wikipedia have started blocking certain images, based on their licensing. So Facebook runs it through a filter (safe_image.php) to check if it is allowed or not. If not, you get a default image. So using FQL will 'sometimes' return you a usable image, but the graph no longer will.
I have no idea if Facebook plan to continue offering the FQL call. Sorry!