Deleting YouTube videos using Zend/PHP - php

I'm using Zend and PHP to upload and delete videos from my home page. The uploading part is working fine but to download is more complicated.
$videoEntryToDelete = $yt->getVideoEntry($videoId);
$yt->delete($videoEntryToDelete);
I use this code to delete a video and the first row do work. The video object is created and I can get all data from it. But when I try to delete it I get this error message:
"You must specify an URI to which to post"
Do anyone know how to solve this problem?
Thanks!

By default, getVideoEntry() gets a read only video object. In order to edit it, you must pass true in the third parameter for getVideoEntry(). The video object will then contain all of the metadata, including the URL required to delete it.
Try this:
$videoEntryToDelete = $yt->getVideoEntry($videoId, null, true);
$yt->delete($videoEntryToDelete);

there is also a method ready to use:
$videoEntryToDelete = $yt->getFullVideoEntry($videoId);
$yt->delete($videoEntryToDelete);

Related

Google Drive PHP v3 API File Metadata

Google specifies the metadata in https://developers.google.com/drive/api/v3/reference/files#resource.
If I do
$parameters['fields']="*";
$files = $service->files->listFiles($parameters);
Then I indeed get pretty much all that.
If I just do
$files = $service->files->listFiles($parameters);
i.e. no fields setting I get a subset, but some fields such as createdTime are now blank - and that is one I need.
Google recommend (https://developers.google.com/drive/api/v3/fields-parameter) listing only the fields you need to improve performance, but just about everything I put in fields gets an error "Invalid field selection" (tested in https://developers.google.com/drive/api/v3/reference/about/get?apix_params=%7B%22fields%22%3A%22createdTime%22%7D)
$parameters['fields']="name,parents,mimeType,filesize,createdTime,modifiedTime";
$files = $service->files->listFiles($parameters);
Any clues as to how this works?
Thanks
I believe your goal as follows.
You want to retrieve the file list using name,parents,mimeType,filesize,createdTime,modifiedTime using Drive API v3 with googleapis for php.
Modification points:
There is no fields of filesize. In this case, it's size.
When the field values of name,parents,mimeType,size,createdTime,modifiedTime are set for the method of "Files: list" of Drive API v3, please use files(name,parents,mimeType,size,createdTime,modifiedTime). I think that the reason of your error message of Invalid field selection name is due to this.
When above points are reflected to your script, it becomes as follows.
Modified script:
From:
$parameters['fields']="name,parents,mimeType,filesize,createdTime,modifiedTime";
To:
$parameters['fields']="files(name,parents,mimeType,size,createdTime,modifiedTime)";
References:
Files
Files: list

Google Drive PHP method listFiles and get return 'thumbnailLink' NULL

I'm using the PHP V2 API. I requested full access (scope: https://www.googleapis.com/auth/drive). I also tried adding all of the different scopes to no avail.
I'm fully able to retrieve all files and list them but the thumbnail link is always null. Same with 'hasThumbnail'.
I tried the API explorer on https://developers.google.com/drive/v2/reference/files/get#examples and it shows me the thumbnail links correctly.
The relevant code can be boiled down to this:
$drive = new Google_Service_Drive($this->client);;
$files = $drive->files->listFiles($parameters)->files;
This is the response from the API explorer.
The response from my code (for the same ID) is:
Found the solution. It took 5 hours to run into this such simple solution.
Not many fields show by default, you must specify which fields you want populated.
The modified basic query now is:
$this->drive->files->listFiles([
'fields' => 'nextPageToken, files(thumbnailLink, webViewLink)'
])->files;

Get Instagram post contents php

I want to develop a PHP project for getting the content of an Instagram post (via the post URL). I mean, for example, the crawler getting this Url and returning :
#TBT Used to love carrying them both at once #twinmom #mycoconuts
#mylifeinmyhands #toobignow #istilltrysometimes #LOVE #forevermybabies
After I used the file_get_contents, the of returned response is empty. I don't know how to fix this problem. Can you help me?
I don't want to use the Instagram API!
You shouldn't use this since it will break as soon as Instagram makes a change to their markup, but here you go:
<?php
$instagram_url = "https://www.instagram.com/p/BX6IowXFbq9";
$source = file_get_contents($instagram_url);
preg_match('/<script type="text\/javascript">window\._sharedData =([^;]+);<\/script>/', $source, $matches);
$data = json_decode($matches[1]);
echo $data->entry_data->PostPage[0]->graphql->shortcode_media->edge_media_to_caption->edges[0]->node->text;
This is little late but I am able to fetch Instagram timeline, Specific Media Details.
E.g:
Fetch user's list of post
If Instagram User page url is https://www.instagram.com/marvel then to fetch this page data you can use below URL
https://www.instagram.com/marvel?__a=1
Fetch specific media post details
If Instagram post detail page url is https://www.instagram.com/p/BfeD8RxHwnC/?taken-by=marvel then to fetch this page data you can use below URL
https://www.instagram.com/p/BfeD8RxHwnC/?taken-by=marvel&__a=1

How to get the picture url using the Facebook PHP SDK

I'm using the latest version of the Facebook PHP SDK (version 4). I finally figured out how to use it in my PHP code. Below is my code.
$user_profile = (new FacebookRequest($this->session, 'GET', '/me/?fields=id,first_name,last_name,picture,timezone,gender,link'))->execute()->getGraphObject(GraphUser::className());
$outputArray[$i]['first_name'] = $user_profile->getFirstName();
$outputArray[$i]['last_name'] = $user_profile->getLastName();
$outputArray[$i]['pictureURL'] = ;
What do i specify to receive the picture URL, i requested it?
Also, i manually opened up the fb php sdk file called GraphUser.php just to see if i can find the property myself. here it is on pastebin.
http://pastebin.com/K6Xg0MjN
As you can see, the GraphUser object doesn't contain any properties that deal with the picture, so where do i get the picture then?
please and thanks for reading
The isn't a field called picture for the user object. It's an edge:
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/picture
$picture_info = (new FacebookRequest($this->session, 'GET', '/me/picture'))->execute()->getGraphObject();
$outputArray[$i]['pictureURL']=$picture_info->getProperty('url');

Fetching profile picture returns empty value

I am trying to access my profile pic at a specified width & height, using PHP SDK via the following code:
$picture = $facebook->api('/me/picture', array('width'=>'160', 'height'=>'160'));
This gives a null array when dumped! But in GRAPH API Explorer, it was giving an array with the URL to the pic!
In API Explorer, this is what I used: /me/picture?width=160&height=160
Similarly, I tried to access just the picture, without passing any arguments. Same effect on that too!
Any idea on why it's happening so?
Thank you
Finally found it!
We have to add redirect=false parameter. Then only it would return the data!
Implementation using PHP SDK:
$picture = $facebook->api('/me/picture', array('width'=>'160', 'height'=>'160', 'redirect'=> 'false'));

Categories