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
Related
I'm having trouble using the API to view a segment. I'm using PHP. My code is as follows:
$url = "https://us7.api.mailchimp.com/export/1.0/list/?apikey=$api_key&id=$list_id&$segment";
$result = file_get_contents($url);
where $segment is an array used to generate the segment.
I can get the following version working...
$segment = "segment[match]=all"
"&segment[conditions][0][field]=LNAME".
"&segment[conditions][0][op]=like".
"&segment[conditions][0][value]=smith";
which generates a segment of all subscribers to my list with a last name containing "smith".
However, what I actually want to do is generate a segment based on people who've been sent any mailer in the last 7 days. I've created this manually to get the correct fields and generated the following array based on it:
$segment = "segment[match]=all".
"&segment[conditions][0][condition_type]=Aim".
"&segment[conditions][0][field]=aim".
"&segment[conditions][0][op]=sent".
"&segment[conditions][0][value]=last7day";
but it's giving me a 300 error. This isn't listed in MailChimp's current error glossary on the export api documentation, but according to a snapshot of the old error documentation means "Campaign doesn't exist" (https://web.archive.org/web/20130209144951/https://apidocs.mailchimp.com/api/1.3/exceptions.field.php) which is weird because I'm not referencing a campaign.
What am I doing wrong?
// , Click on playground and with your API key.
Generate some responses and look at the campaign id.
It's not the integer value you see when hovering over the campaign with id=, it's another value.
Look for the id that the API needs in the response.
This will fix your issue.
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;
In bigcommerce site I want functionality like anonymous users can upload image for products which he wants to purchase and add to cart.Like this (http://www.woowoonails.com/) site.
When you will open this link you will see Design Your Own Nail Wraps! container on home containing link user your own photos when you will click on this you will be on this link (http://www.woowoonails.com/designer/layout).Here you can upload your photos and click on add to bag. Same functionality I want on my site but I did not get any idea.Bigcommerce team does now allow to upload php file to their server.Then I tried to use api.
But I am not able to configure it.I have downloaded the api from (github.com/bigcommerce/bigcommerce-api-php) .But I am not getting idea how to configure it and use.
I have also download the single php file(raw.github.com/bigcommerce/bigcommerce-api-php/master/bigcommerce.php) and put it inside the Bigcommerce1 folder and then include in my file containing code:
require 'Bigcommerce1/bigcommerce.php';
BigCommerce_Api::configure(array(
'store_url' => 'siteurl',
'username' => 'admin',
'api_key' => 'df38dd10e9665a3cfa667817d78ec91ee9384bc3'
));
But nothing work.Can you give me some light about how can I achieve the functionality to upload photos and also about api configuration.
Thanks
You want to use the FTP not the BigCommerce API to capture the image... BigCommerce does support file uploading, but from what I have read it is an afterthought and is not configurable via the API. It is easier therefore to have an iframe for file upload, capturing the file contents and uploading it to the bigC (s)FTP server for storage...
This means you could post a file to any other site (so hosted externally) upload it to the FTP under some unique id, and when the order was submitted re-join the two.
Also to connect to the BigCommerce API, it is best to write or use a wrapper function library around BigCommerce
so for example we made the library object-based due to errors and undesirable functionality in the PHP version of the API, and a difference in coding styles, so we just use the following to get all orders 'Awaiting Fulfillment' and work from there...
$bcAPI = new bigcommerceAPI();
$orders = $bcAPI->getOrders();
$orders = array_filter($orders,function($data){ if($data->status == 'Awaiting Fulfillment'){ return true; } return false; });
I need a way to display videos from a specific channel on a page using PHP.
I have authenticated my app and I can use some methods using the advanced API. I am using the official vimeo PHP library to connect.
Below is what I am trying to do and when I dump the array I do not get anything. I can get info back from using get videos from the entire account method.
require_once('/url/vimeo/vimeo.php');
$vimeo = new phpVimeo('number', 'number');
$vimeo->setToken('number','numbers');
$videos = $vimeo->call('vimeo.channels.getVideos', array('ACCOUNT' => 'NAME'));
If I put the channel name where ACCOUNT is I will get an invalid signature error.
Is it worth using something like simple HTML parser for PHP and doing it that or worth sticking with the advanced API?
I would highly advise using the advanced api. If you parse the html, it will break any time vimeo changes their channel pages. Additionally, channels have more than one layout
eg: vimeohq and nicetype
The second parameter of the "call" function should be any querystring parameters the api method requires.
In the case of "vimeo.channels.getVideos" you can provide
channel_id
user_id
page
per_page
summary_response
full_response.
To experiment with the getVideos method, you can use the playground.
So in the end, I believe you want the function to look like this..
$videos = $vimeo->call('vimeo.channels.getVideos', array('channel_id' => 'NAME'));
where NAME is either the channel id, or the channel name (the channel name matches the url slug, so for example "nicetype" not "nice type"
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);