Received error response when Get a Facebook user's basic info - ios

I'm doing it on ios. When I get a user's info(gendar,locale,etc), such as Bill Gates(216311481960), it will return error. Maybe because these info are not public. If I just get name,link, picture, that will be OK. But how can I handle this kind of error. How can I know which info can be retrieved?
Thanks.

Without a user access token, pubic info can be grabbed this way: http://graph.facebook.com/216311481960
{
"id": "216311481960",
"name": "Bill Gates",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/276582_216311481960_498814368_s.jpg",
"link": "http://www.facebook.com/BillGates",
"likes": 1216122,
"category": "Public figure",
"is_published": true,
"website": "www.thegatesnotes.com www.gatesfoundation.org",
"username": "BillGates",
"talking_about_count": 25035
}
As you can see this doesn't appear to be user information, but rather page information.
For user information, you need to use a Facebook user id. Zuck's is 4...so do: http://graph.facebook.com/4
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
Notice how it has both first_name and last_name, while the "Bill Gates" one you have as an example is clearly not a "user" but a page.
With a valid user access token, all shared information can be grabbed this way:
http://graph.facebook.com/me?access_token=ValidUserAccessToken

Related

Creating multiple resources in tandem with JSONAPI:Resources for Rails

On my application, I would like to add a post and user in tandem using jsonapi:resources. A user can be created already. And a post can be created already if someone is signed in. However for this special scenario I would like a user to be able to submit their first post while creating their account. Here is the payload that would be submitted.
{
"data":{
"user":{
"attributes":{
"name": "blah blah",
"age": 20,
"address": "mickey mouse street"
}
},
"relationships": {
"post": {
"content": "this is a new post",
"type": "blog"
}
}
}
}
Is this at all possible? If so in which resource file would I create them both? Would it be the resource file for posts or for users? Or would it be best practice to create the user first and then once the user has been created make a separate call to create the post? Thanks!

Error while validating epub in epubcheck, it says this

Error while parsing file: element "ruby" not allowed anywhere;
expected the element end-tag, text or element "a", "abbr", "acronym",
"applet", "b", "bdo", "big", "br", "cite", "code", "del", "dfn", "em",
"i", "iframe", "img", "ins", "kbd", "map", "noscript", "ns:svg",
"object", "q", "samp", "script", "small", "span", "strong", "sub",
"sup", "tt" or "var" (with xmlns:ns="http://www.w3.org/2000/svg")
and the code where it is pointing this error looks like this
<p>i don't want this<ruby>Artifact<rt>Variable Drag-Ride</rt></ruby>.</p>
can you tell me why this error is coming
Ruby tags should be supported in epub3 (search for "ruby" in this reference) but here the element is probably inside a tag where it's not allowed (xhtml is very strict).
Search for the sentence and look for the previous tags, they may have some restrictions resulting in this error on epubcheck.

JSON for passing multiple records to POST request to rails API create action?

I have a simple API built using
rails new my_api --api
Then
rails g scaffold Model name age
I can make a new record using curl POST request like so
curl -H "Accept: application/json" -H "Content-type: application/json" -d '{"name": "Fred", "age": "5"}' "http://localhost:3000/model_name"
Question
Is it possible to submit multiple new records in the same POST request? And if so, what should the JSON look like?
What I've tried so far
I've tried variations of {"name": "Fred", "age": "5"}, like {"name": ["Fred", "Mary"], "age": ["5", "6"]}
The API doesn't reject this JSON, instead, it creates 1 record (not 2), and the values are nil instead of the actual data.
Note
The current controller code is
def create
#model = Model.new(model_params)
if #model.save
render json: #model, status: :created, location: #model
else
render json: #model.errors, status: :unprocessable_entity
end
end
Short answer, yes.
You built the API, you define exactly what that POST request will receive and how it will handle it. Rails scaffold auto generated create method will not accept multiple records at once in a JSON though. You must open the controller file that was generated by rails scaffold and change it to accept multiple records.
And a little hint, try this structure for a JSON with multiple records:
[{"name": "Fred", "age": "5"}, {"name": "Fred", "age": "5"}, {"name": "Fred", "age": "5"}]

Pulling data from Facebook Graph API 2.0 Object

I'm working in Koala with Facebook's Graph API 2.0. Now when you call user_friends using
<% #friends = #graph.get_connections("me", "friends") %>
You should get an object that contains something like the following:
{
"data": [
{
"name": "Friend 1",
"id": "xxxxx"
},
{
"name": "Friend 2",
"id": "xxxx"
},
],
"paging": {
"next": "https://graph.facebook.com/v2.1/...."
},
"summary": {
"total_count": number of friends
}
}
My question is how do I pull the information from summary. I tried printing this in my ruby app but I only saw the following:
[]
Does that mean the return was nil? I tried to call #friends.summary, but that didn't work
Thoughts?
https://developers.facebook.com/docs/apps/changelog
The list of friends returned via the /me/friends endpoint is now limited to the list of friends that have authorized your app.
Also make sure you authorized yourself with the user_friends permission, of course.

docusign_rest gem not populating tab from template

I am trying to test the docusign_rest gem for possible integration into my rails app. I have set up the gem and configured it with my username, password, and integrator key. I have set the version of the api to 'v2' and checked all the of the names of both the signers and the tab fields multiple times. Here is the code I am using to make the request:
response = c.create_envelope_from_template(
status: 'sent',
email: {
subject: "Test email subject",
body: "Test email body",
},
template_id: template["templateId"],
signers: [
{
embedded: false,
name: "Name",
email: 'example#gmail.com',
role_name: "Signer1",
tabs: {
textTabs: [
{
tabLabel: "\\*address",
value: "123 Example St.",
locked: true
}
]
}
}
]
)
The request gets sent and the envelope gets sent but the 'address' field is not populated. Is there anything I am doing obviously wrong?
Thanks in advance.
Try changing the signers node in you request body to templateRoles. When you use templates in DocuSign instead of specifying the signers and their types and tabs, you assign them to existing template roles that are configured in the template. That's why no signer types should be specified in this call, just the template roles that each recipient will get matched to, and the values of any tabs you want to populate.
I've never used Ruby before so there might be some formatting or syntax issues I'm missing here, and I also have never seen the ruby gem you're referring to so not sure how stable or correct that code is. But basically this is what I think you need to do...
Right now you have:
status: 'sent',
email: {
subject: "Test email subject",
body: "Test email body",
},
template_id: template["templateId"],
signers: [
{
...
Try changing signers to templateRoles, like so:
status: 'sent',
email: {
subject: "Test email subject",
body: "Test email body",
},
template_id: template["templateId"],
templateRoles: [
{
...
The resulting http request body that you need to construct should look something like the following (in JSON format):
{
"emailSubject": "DocuSign API - Signature Request from Template",
"templateId": "ABCD1234",
"templateRoles": [
{
"email": "firstperson#email.com",
"name": "John Doe",
"roleName": "Template Role Name goes here",
"tabs": [
{
"textTabs": [
{
"tabLabel": "\\*address",
"value": "432 Sorrento Dr.",
"locked": "true"
}
]
}
]
}
],
"status": "sent"
}
Lastly, the DocuSign API Walkthrough for requesting a signature from a template is a great resource for sending from a template so this might help too. There's sample code for making this api call in 6 different languages (unfortunately Ruby is not one of them):
http://iodocs.docusign.com/APIWalkthrough/requestSignatureFromTemplate
Finally figured it out myself by modifying the gem to inspect the request. With the docusign_rest gem, the documentation on the github page is incorrect. The tabs dictionary should not be there and the items in this specific request should be underscore separated instead of camel case. Therefore, the actual request would look something like:
response = c.create_envelope_from_template(
status: 'sent',
email: {
subject: 'Test email subject',
body: 'Test email body',
},
template_id: template["templateId"],
signers: [
{
embedded: false,
name: 'Name',
email: 'example#gmail.com',
role_name: 'Signer1',
text_tabs: [
{
label: 'Address',
name: 'Address',
value: '123 Example Street.',
}
]
}
]
)
This request will allow you with the gem and v2 of the api to create an envelope from a template and prepopulate any fields. All other field types go the same way as the text_tabs array.

Resources