I am new to php and trying to set up a simple rest api.
The link to the github repository:
https://github.com/deepmandal7/slim-restapi-crud
I have replaced mysql with postgresql and the credentials have been included in the .env.example. It is a free tier in elephantsql. But when I send a post request like so:
POST /api/v1/products
{
"title": "some title",
"description": "some description",
"image_url": "some url,
}
It doesn't get saved in the database and there's no error either.
Related
I want to build an app that can monitor one Glip team for posts including screenshots and then post that message to another Glip team. I can read a post, download an attachment and repost / upload it, but is there a way to simply share an existing attachment without reposting it. This can be done in the app UI but I didn't see a share API in the Glip API Reference.
Here's the Glip API Reference which includes endpoints for creating, reading, updating and deleting posts but not sharing:
https://developers.ringcentral.com/api-reference/team-messaging
The icon for sharing is the 6th from the left in the app screenshot below.
Is there a way to do this in Glip without downloading and re-uploading the file?
To share an attachment via the Glip API, create a new post with an existing attachment.
Create Post API
The Create Post API takes an optional attachments array which references existing attachments. Both the id and type properties are required. Both properties are present in the post API response.
POST /restapi/v1.0/glip/chats/{chatId}/posts
{
"text": "Please check out this file",
"attachments": [
{
"id":"123456789",
"type":"File"
}
]
}
Ref: https://developers.ringcentral.com/api-reference/Posts/createGlipPost
Example Get Posts API
The following is an example of a post showing the attachments array with the id and type properties. The attachment URL is an AWS Presigned Object URL as shown below.
GET /restapi/v1.0/glip/chats/{chatId}/posts
{
"records": [
{
"id": "11111111",
"creatorId": "22222222",
"creationTime": "2019-08-26T21:41:56.648Z",
"lastModifiedTime": "2019-08-26T21:41:56.648Z",
"type": "TextMessage",
"chatId": "33333333",
"mentions": [],
"attachments": [
{
"id": "123456789",
"name": "sharedfile.png",
"contentUri": "https://glip-vault-1.s3.amazonaws.com/web/customer_files/44444444/testimage.png?Expires=55555555&AWSAccessKeyId=myAccessKeyId&Signature=myAWSPresignedObjectUrlSignature",
"type": "File"
}
],
"text": "Check this out!"
}
},
"navigation": {}
}
Ref: https://developers.ringcentral.com/api-reference/Posts/readGlipPosts
Sharing Permissions
Attachments can only be shared by the original poster or within the same chat. If a different user wants to share an attachment in a different team, it will be necessary to download and repost the file, generating a new attachment id.
If a different user attempts to share an attachment in a different chat, a 403 Forbidden error will be encountered:
403 Forbidden
{
"errors": [
{
"errorCode": "PST-011",
"message": "The requester must be attachment creator or attachment must belong to the requested chat."
}
]
}
Using v2 of LinkedIn REST API I'm searching for a way to post an article to my company's LinkedIn page.
I've signed up here https://business.linkedin.com/marketing-solutions/marketing-partners/become-a-partner/marketing-developer-program and currently waiting to be approved.
I want to be able to create a blog post on my company website and when i press 'publish' i want to post that blog post, as an article, to my companys LinkedIn page.
The closest i've been to finding information regarding this topic is https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/articles-api
But this does not disclose any information for posting articles, only retrieving and deleting them
You can share articles to your LinkedIn company feed using content entities (contentlocation and thumbnail). You can also provide a title and description for the article you want to share.
An example of a share with article is as follows:
{
"owner": "urn:li:organization:12345",
"content": {
"contentEntities": [{
"entityLocation": "https://www.example.com/content.html",
"thumbnails": [{
"resolvedUrl": "https://www.example.com/image.jpg"
}]
}],
"description": "content description",
"title": "Test Company Share with Content"
},
"text": {
"text": "This is a share with an article"
}
}
Documentation for this API endpoint can be found here:
https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api#share-content.
Hope it helps!
With the new UGCPost APIs, you should use the Create UGC Posts method (Documentation).
To use the method, after authentication, you will use:
POST https://api.linkedin.com/v2/ugcPosts
with the author as your organization, such as "urn:li:organization:5590506". Also, to do so, you will need the w_organization_social permission with one of the following roles:
ADMINISTRATOR
DIRECT_SPONSORED_CONTENT_POSTER
RECRUITING_POSTER
I have a Rest API that allows users to POST to an endpoint to upload a photo:
POST /api/photos
The response would be as follows:
{
"id": "1",
"title": "my image"
"url": "https://some_s3_url"
}
The user can then access the photo metadata through the GET endpoint
GET /api/photos/1
What is the best way to model a url for getting the content of the image url? Note that I'd like to ensure the user has the ability to access this image, so requesting the s3 bucket url directly will not work here.
I have considered doing something like:
GET /api/photos/1/content
Though that seemed hacky
first of all POST request should not return response, it could return header called location to return URI of created resource for ex. http://youer-server/api/photos/1 then in GET request for this URL you can return the json object as:
{
"id": "1",
"title": "my image",
"url": "https://some_s3_url",
"base64": .....
}
then you can encode your image as base64 and provide its content in the same object.
I am using this URL to access facebook likes off of an authorized and logged in user:
https://graph.facebook.com/v2.3/me/likes?access_token=accessToken
it returns this
"data": [
{
"name": "Page Name",
"category": "Category name",
"id": "12345678",
"created_time": "2012-03-26T08:02:01+0000"
},
However on my new app which uses API 2.5
https://graph.facebook.com/v2.5/me/likes?access_token=accessToken
it returns this
"data": [
{
"name": "Page Name",
"id": "12345678",
"created_time": "2012-03-26T08:02:01+0000"
},
Which is minus the category name.
I have my new app registered in FB and it will not allow me change API from 2.5, and even on my new app if I use the 2.3 URL it will still not display categories.
Does anyone know what extra calls I need to make to get categories or why they have disapeared in newer versions of the API, I can't find anything on google or on FB's doco's
It´s called "Declarative Fields", check out the changelog for v2.4: https://developers.facebook.com/docs/apps/changelog#v2_4
That´s what you need to change:
/me/likes?fields=name,category&access_token=accessToken
When using the requests dialog, facebook issues a notification like this:
What I'm looking to achieve is for the user to click the request link shown above and to present a "Random User invited you to..." message on our App.
However, when clicking that link Facebook doesn't seem to pass through the id of "Random User" to the App. The url accessed by the link looks something like:
http://apps.facebook.com/randomcomp/?fb_source=notification&request_ids=350578327437399,350578327437399&ref=notif&app_request_type=user_to_user¬if_t=app_request
which doesn't contain any reference to the user who initiated the request.
From the App's side, there doesn't seem to be a way to get this information from Facebook. Sure, you can get a list of requests, but that list can contain information for many requests, including requests from other users in addition to the one we're interested in, so it's not useful in this case. For example, here's a snapshot of data:
{
"data": [
{
"id": "340083146057323_100003817986566",
"application": {
"name": "Random Competition",
"namespace": "randomcomp",
"id": "350578327437399"
},
"to": {
"name": "Hannah Smith",
"id": "100003817986566"
},
"from": {
"name": "Random User",
"id": "100002286042525"
},
"data": "100002286042525",
"message": "Use the app!",
"created_time": "2012-05-14T13:26:30+0000"
}, {
"id": "358318457550141_100003817986566",
"application": {
"name": "Random Competition",
"namespace": "randomcomp",
"id": "350578327437399"
},
"to": {
"name": "Hannah Smith",
"id": "100003817986566"
},
"from": {
"name": "Jane Young",
"id": "100003771838663"
},
"data": "100002286042525",
"message": "Use the app!",
"created_time": "2012-05-14T10:54:25+0000"
}],
}
}
As you can see, the data is being passed in, but there's still no way to join the click from the link mentioned above (for Random User) to the correct request in the list; the link passes through the ID for both requests, not just the one for Random User, and while the link states "Random User" it doesn't pass through an identifier.
Am I missing something? Is there a mechanism that isn't in the docs that will allow me to pick-up the "Random User" id so I can provide a nice "Random User invited you to..." message in the App when they click through?
Edit:
Turns out that this isn't possible - see my answer.
You can add some data to the request so that when you process the request you can differentiate that from other requests.
The data can be sent with app requests and users requests and the parameter name is "data".
For example, in the guide for the Requests Dialog you can see it in the properties table at the (almost) end of the document, it says:
Optional, additional data you may pass for tracking. This will be
stored as part of the request objects created. The maximum length is
255 characters
There's also some info about it in the Social Channels documentation, and a sample of (php) usage in the official blog post about Upgrade to Requests 2.0.
I hope that this is what you're looking for.
Edit
When you send the request you know who is sending it right? It's the logged in user, and so you can put the user id/name/etc in the data parameter of the request.
Then, when someone clicks on a request, get the request by the id that facebook passes to you, and from the data extract the user id of the sender.
As the documentation states, you have 255 characters to use, and with that you can do what ever you want, you can even serialize an object to that parameter and deserialize it later.
As it turns out, this is in fact not possible at all.
The link, as shown in the image below, can present multiple users:
which is why multiple request IDs are passed in, and the sender's ID isn't.