How to Like Youtube Video with Youtube Api v3 using php - php

Since Youtube Api V2 doesn't support like a specific video anymore. Can anyone please explain how to like a video with youtube api v3 ?
I am always getting the following response:
Response
400 Bad Request
- Show headers -
{
"error": {
"errors": [
{
"domain": "youtube.part",
"reason": "unexpectedPart",
"message": "contentDetails",
"locationType": "parameter",
"location": "part"
}
],
"code": 400,
"message": "contentDetails"
}
}
The request is :
Request
POST https://www.googleapis.com/youtube/v3/activities?part=snippet&key={YOUR_API_KEY}
Content-Type: application/json
Authorization: Bearer ya29.AHES6ZQUI8Gn7j93QZBmmdlDe7Ei-iqYseYAKAxyf3qTOHHwDHb-dA
X-JavaScript-User-Agent: Google APIs Explorer
{
"contentDetails": {
"like": {
"resourceId": {
"videoId": "video-id",
"kind": "youtube#video"
}
}
}
}
The part is = snippet
I am following these docs : https://developers.google.com/youtube/v3/docs/activities/insert

The answer is already in the comments, but to elevate it a bit: YouTube API v3: Liking a video in Python has more information about liking a video, though the example there is in Python.
The important part is that liking a video is done via a playlistItems.insert() call, not an activities.insert() call. This is a common source of confusion and I've already asked our tech writer to try to clear things up in the docs.

Related

Create Local post on Google My Business Issue

Attempting to create Google My Business Local Post using My Business API and PHP.
A Local Post is created just fine EXCEPT when adding the mediaItem object to the post body.
Getting the error :
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"errors": [{
"message": "Request contains an invalid argument.",
"domain": "global",
"reason": "badRequest"
}],
"status": "INVALID_ARGUMENT"
}
}
Below is the post object with mediaItem that is being sent to localPosts->create
$new_post = new Google_Service_MyBusiness_LocalPost();
$new_post->setSummary('Hello World');
$new_post->setLanguageCode('en-US');
$media = new Google_Service_MyBusiness_MediaItem();
$media->setMediaFormat("PHOTO");
$media->setSourceUrl("https://www.webyhub.com/img/logo.png");
$new_post->setMedia($media);
You will need to do this on Postman to get the detail validation message as to why the image you used is invalid.
Try Advanced Rest Client (or Postman), make a POST request to https://mybusiness.googleapis.com/v4/accounts/{uuid}/locations/{uuid}/localPosts with
Header: Authorization: Bearer {access_token}.
Body Content Type: application/json
Body:
{
"summary":"test",
"topicType":"STANDARD",
"media":[{"mediaFormat": "PHOTO","sourceUrl": "https://example.com/files/test.jpg"}]
}
Also, Creating Post with video uploading is not currently available. I dont know why but I am also stuck on this matter.

Create user with other mail provider in Azure AD B2C (gmail,etc...)

I used Microsoft Graph API PHP SDK to add user in my Azure Active Directory B2C. I managed to create users with a userPrincipalName like name#mytenantid.onmicrosoft.com.
I wasn't able to add users with a GMail address such as john.doe#gmail.com.
I tried to add the signInNames collection but I got the following response:
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error:
POST https://graph.microsoft.com/v1.0/users resulted in a 400 Bad Request
response:
{ "error": {
"code": "Request_BadRequest",
"message": "Invalid property 'signInNames'.",
"innerError": (truncated...)
Here is my JSON request body :
{
"accountEnabled": true,
"displayName": "John Doe",
"userPrincipalName": "john#doe.fr",
"creationType": "LocalAccount",
"passwordProfile" : {
"forceChangePasswordNextSignIn": true,
"password": "P#!ssWor?D"
},
"signInNames": [
{
"type": "emailAddress",
"value": "john#doe.fr"
}
]
}
You're confusing Microsoft Graph API with the Azure AD Graph API. These are two different APIs. While they share a lot of functionality, calls to these APIs are not interchangeable.
The User object in Microsoft Graph API doesn't support a signInNames property. This is why it is returning that error.
Local account users are not supported by Microsoft Graph API at the moment.
In case if someone will still have the same problem, in MS Graph Api you can use "identities" instead of "signInNames" and your JSON will look like
{
"accountEnabled":true,
"displayName":"John Doe",
"userPrincipalName":"john#doe.fr",
"creationType":"LocalAccount",
"passwordProfile":{
"forceChangePasswordNextSignIn":true,
"password":"P#!ssWor?D"
},
"identities":[
{
"signInType":"emailAddress",
"issuer":"<your tenant domain name>",
"issuerAssignedId":"john#doe.fr"
}
]
}

Get private YouTube video details

I want to get a logged in user's private YouTube video details using the v3 API. I have already extended my Google Oauth authentication with YouTube scope. The login process was success. The owner of the private video is the logged in user.
However if I use the following request I got a valid success message but with a 0 result.
My request:
https://www.googleapis.com/youtube/v3/videos?part=contentDetails,snippet&id=VIDEO_ID&key=API_KEY
Response:
{
"kind": "youtube#videoListResponse",
"etag": "\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 0
},
"items": []
}
Any idea what can be the problem?
Finally I have found the problem. The Google OAuth access token was not part of the request header. After including it in the request the response gave me the correct result.

Facebook - Send friend request (User to User) using graph API and PHP SDK?

So I was wondering faecebook docs hasn't mention it in its official docs on Developers
but I have seen the graph call on blogs but it works (that's the weird thing)
https://graph.facebook.com/me/friends?method=post&uids=< USER ID>&access_token=< Acccess Token>
The respond is
{
"error": {
"message": "(#200) ",
"type": "OAuthException",
"code": 200
}
}
Is this possible to do? if yes, How can I do it with PHP SDK?
any idea is accepted
You can use the Friends Dialog. To integrate you can use javascript as-
FB.ui({
method: 'friends',
id: USER_ID
}, function(response){});
OR, a URL redirect as-
https://www.facebook.com/dialog/friends/?
id=USER_ID
&app_id=APP_ID
&redirect_uri=REDIRECT_URI
For more details: Friends Dialog

PHP Google Play Subscription API

I am trying to get Google Play API subscription details using PHP and using following url to get purchase data :
https://www.googleapis.com/androidpublisher/v1/applications/[PACKAGE]/subscriptions/[SKU]/purchases/[PURCHASE_TOKEN]?access_token=[ACCESS_TOKEN]
I am getting the following error:
{
"error": {
"errors": [
{
"domain": "androidpublisher",
"reason": "developerDoesNotOwnApplication",
"message": "This developer account does not own the application."
}
],
"code": 401,
"message": "This developer account does not own the application."
}
}
Please help me sort out.
Just providing the URL does not help you get data of any application. How can you think so.? Isnt it insecure.? You have to get proper data by which you can at least prove ownership for the app..

Categories