Listing files and directories returns mixed case sensitivity on the results. Is there a way to force case sensitive results? - dropbox-api

I've created a folder structure as below, with some images in the subfolders.
Test 1
Test 2.1
Test 2.1.1
Test 2.1.2
Test 2.2
When calling 'getMetadataWithChildren' I seem to be having mixed case results returned such as:
Array
(
[hash] => fd2934448f39ea3aa37faca9bbf72beb
[revision] => 14666
[rev] => 394a08b41a0c
[thumb_exists] =>
[bytes] => 0
[modified] => Thu, 10 Jul 2014 11:18:25 +0000
[path] => /Test 1/Test 2.1
[is_dir] => 1
[icon] => folder
[root] => dropbox
[contents] => Array
(
[0] => Array
(
[revision] => 14672
[rev] => 395008b41a0c
[thumb_exists] => 1
[bytes] => 879394
[modified] => Thu, 10 Jul 2014 11:18:25 +0000
[client_mtime] => Tue, 14 Jul 2009 05:32:31 +0000
[path] => /test 1/Test 2.1/Chrysanthemum.jpg
[is_dir] =>
[icon] => page_white_picture
[root] => dropbox
[mime_type] => image/jpeg
[size] => 858.8 KB
)
[1] => Array
(
[revision] => 14670
[rev] => 394e08b41a0c
[thumb_exists] =>
[bytes] => 0
[modified] => Thu, 10 Jul 2014 11:18:25 +0000
[path] => /test 1/Test 2.1/Test 2.1.1
[is_dir] => 1
[icon] => folder
[root] => dropbox
[size] => 0 bytes
)
[2] => Array
(
[revision] => 14671
[rev] => 394f08b41a0c
[thumb_exists] =>
[bytes] => 0
[modified] => Thu, 10 Jul 2014 11:18:25 +0000
[path] => /test 1/Test 2.1/Test 2.1.2
[is_dir] => 1
[icon] => folder
[root] => dropbox
[size] => 0 bytes
)
)
[size] => 0 bytes
)
Note that in the 'contents' array, the path is not the same as the path provided (and as named in my Dropbox). I need the results to be the correct case sensitivity for grouping them in my application so am I missing something simple or is this an issue with the Dropbox API and the results that are returned?
Many thanks in advance!

Related

How to connect to suite CRM REST API using Guzzle

I'm trying to connect to suite CRM REST API using Guzzle
$res = $client->request('GET','http://crm.demo.com/service/v4_1/rest.php/login', [ "auth" => [ 'myadmin', md5('mypswd') ]]);
print_r($res);
The result I'm getting is this
GuzzleHttp\Psr7\Response Object
(
[reasonPhrase:GuzzleHttp\Psr7\Response:private] => OK
[statusCode:GuzzleHttp\Psr7\Response:private] => 200
[headers:GuzzleHttp\Psr7\Response:private] => Array
(
[Date] => Array
(
[0] => Mon, 03 Apr 2017 06:26:17 GMT
)
[Content-Type] => Array
(
[0] => text/html; charset=UTF-8
)
[Transfer-Encoding] => Array
(
[0] => chunked
)
[Connection] => Array
(
[0] => keep-alive
)
[Set-Cookie] => Array
(
[0] => __cfduid=daace974785b1e202e7535232346958d111491200776; expires=Tue, 03-Apr-18 06:26:16 GMT; path=/; domain=.demo.com; HttpOnly
)
[X-Powered-By] => Array
(
[0] => PHP/5.4.16
)
[X-Varnish] => Array
(
[0] => 2592144
)
[Age] => Array
(
[0] => 0
)
[Via] => Array
(
[0] => 1.1 varnish-v4
)
[Server] => Array
(
[0] => cloudflare-nginx
)
[CF-RAY] => Array
(
[0] => 3499f497d6bd17a4-SIN
)
)
[headerNames:GuzzleHttp\Psr7\Response:private] => Array
(
[date] => Date
[content-type] => Content-Type
[transfer-encoding] => Transfer-Encoding
[connection] => Connection
[set-cookie] => Set-Cookie
[x-powered-by] => X-Powered-By
[x-varnish] => X-Varnish
[age] => Age
[via] => Via
[server] => Server
[cf-ray] => CF-RAY
)
[protocol:GuzzleHttp\Psr7\Response:private] => 1.1
[stream:GuzzleHttp\Psr7\Response:private] => GuzzleHttp\Psr7\Stream Object
(
[stream:GuzzleHttp\Psr7\Stream:private] => Resource id #73
[size:GuzzleHttp\Psr7\Stream:private] =>
[seekable:GuzzleHttp\Psr7\Stream:private] => 1
[readable:GuzzleHttp\Psr7\Stream:private] => 1
[writable:GuzzleHttp\Psr7\Stream:private] => 1
[uri:GuzzleHttp\Psr7\Stream:private] => php://temp
[customMetadata:GuzzleHttp\Psr7\Stream:private] => Array
(
)
)
)
Its showing the request was successful but I'm not getting the result. Is it really possible to connect it using Guzzle? Is there any other method to pass the login parameters?
I'm using CodeIgniter 3 and Guzzle to achieve this.
First of all, what's the issue? You code is correct, you get the response.
If you want to explore the response body, just do (string) $res->getBody() or $res->getBody()->getContents() (the body is a stream, as you can in your dump, so to get it as a string you have to do additional actions).
BTW, you are trying to access a site under CloudFlare, and usually it's not possible, because CloudFlare rejects robots. Try to get a different entry point (that is not under CloudFlare protection).

Yii2 Facebook Login issue: Error Validating Client Secret

I'm trying to activate Login via Facebook on my website that is built using Yii2 framework, but the Login is always failing, although the facebook app is authorizing the facebook account used in the login.
The response is always this error:
Request failed with code: 400, message: Error validating client
secret.
Im using yii2's authclient:
return [
'class' => 'yii\authclient\Collection',
'clients' => [
'facebook' => [
'class' => 'yii\authclient\clients\Facebook',
'authUrl' => 'facebook.com/dialog/oauth',
//Prod
'clientId' => 'appidhere',
'clientSecret' => 'appsecrethere',
'scope' => 'email, user_friends, public_profile',
.....
The app id and app secret are correct, and the fb app settings are correct as well.
Here's what the request looks like:
yii\httpclient\Request Object ( [_url:yii\httpclient\Request:private]
=> graph.facebook.com/oauth/access_token [_fullUrl:yii\httpclient\Request:private] =>
[_method:yii\httpclient\Request:private] => POST
[_options:yii\httpclient\Request:private] => Array ( [userAgent] => My
Application OAuth 2.0 Client [timeout] => 30 [sslVerifyPeer] => )
[isPrepared:yii\httpclient\Request:private] => [client] =>
yii\httpclient\Client Object ( [baseUrl] => graph.facebook.com
[formatters] => Array ( ) [parsers] => Array ( ) [requestConfig] =>
Array ( ) [responseConfig] => Array ( ) [contentLoggingMaxSize] =>
2000 [_transport:yii\httpclient\Client:private] =>
yii\httpclient\StreamTransport [_events:yii\base\Component:private] =>
Array ( ) [_behaviors:yii\base\Component:private] => )
[_headers:yii\httpclient\Message:private] =>
[_cookies:yii\httpclient\Message:private] =>
[_content:yii\httpclient\Message:private] =>
[_data:yii\httpclient\Message:private] => Array ( [client_id] =>
realappidhere [client_secret] => ​realappsecrethere [code] =>
AQAr0KRC0m4V4lqD8LVcQLNjn76xkZS4skQYAvWf6O_DDeEclaj1LMQm_HoyCoZZezqDn7p9YfJm3qENabU8MKvmH1ffNJotMzgLW2XTbSqQEXlkg_sx7V-ibXRFagpfXTIqCp9Kr54O88bNYGikoOr4TM1ogGjViwS-qKLbvpR_vWgE_FPy9ecpgy86QOITpGrlVJaPAun2bzGaFXmU70Z4Kw3kBWUBPseWc_7ILGymZP-CIbRIIm_YZ8p7t9Vo7jZmieMSd-CMYfG0sgJcBjOgQNvsa3xtHNhPVa5BJNNTy89zulSpTAf3XB6HB_8eql0
[grant_type] => authorization_code [redirect_uri] =>
example.com/site/auth?role=influencer&authclient=facebook )
[_format:yii\httpclient\Message:private] =>
[_events:yii\base\Component:private] => Array ( )
[_behaviors:yii\base\Component:private] => )
And the response is:
yii\httpclient\Response Object ( [client] => yii\httpclient\Client
Object ( [baseUrl] => graph.facebook.com [formatters] => Array
( [urlencoded] => yii\httpclient\UrlEncodedFormatter Object (
[encodingType] => 1 [charset] => ) ) [parsers] => Array ( )
[requestConfig] => Array ( ) [responseConfig] => Array ( )
[contentLoggingMaxSize] => 2000
[_transport:yii\httpclient\Client:private] =>
yii\httpclient\StreamTransport Object (
[_events:yii\base\Component:private] => Array ( )
[_behaviors:yii\base\Component:private] => )
[_events:yii\base\Component:private] => Array ( )
[_behaviors:yii\base\Component:private] => Array ( ) )
[_headers:yii\httpclient\Message:private] => Array ( [0] => HTTP/1.1
400 Bad Request [1] => WWW-Authenticate: OAuth "Facebook Platform"
"invalid_request" "Error validating client secret." [2] =>
Access-Control-Allow-Origin: * [3] => Pragma: no-cache [4] =>
Cache-Control: no-store [5] => facebook-api-version: v2.2 [6] =>
Expires: Sat, 01 Jan 2000 00:00:00 GMT [7] => Content-Type:
text/javascript; charset=UTF-8 [8] => x-fb-trace-id: Ek0PFIJ3B3N [9]
=> x-fb-rev: 2718923 [10] => Vary: Accept-Encoding [11] => X-FB-Debug: yaiIHJkwC4T3UZKrzXOJGJ2DmCTaDr8nIRB3jQnNeEiknx0Ph7i2IR5XmAbxpjM7cBhSEy44AcrglCYEdZEmeg==
[12] => Date: Sun, 04 Dec 2016 11:08:16 GMT [13] => Connection: close
[14] => Content-Length: 115 )
[_cookies:yii\httpclient\Message:private] =>
[_content:yii\httpclient\Message:private] =>
> {"error":{"message":"Error validating client
secret.","type":"OAuthException","code":1,"fbtrace_id":"Ek0PFIJ3B3N"}}
[_data:yii\httpclient\Message:private] =>
[_format:yii\httpclient\Message:private] =>
[_events:yii\base\Component:private] => Array ( )
[_behaviors:yii\base\Component:private] => )
So any idea what's happening in there?
Note: I removed the http and https from the facebook links in the quotes because stackoverflow wouldn't let me post more than 2 links.
Try using Yii2 EAuth extension. This is the best extention which provides social login over 14 diff platforms with the easiest way.
reference url:
https://github.com/Nodge/yii2-eauth
demo url : http://nodge.ru/yii-eauth/demo2/login

(Salesforce Force.com REST API) How do I determine which products are associated with opportunities?

I'm using the Salesforce Force.com REST API. I need to determine which Products (Product2) are associated with Opportunities (Opportunity). Thus far, I've been unable to make the connection.
In the Salesofrce UI, opportunities can be associated with pricebooks and products. Pricebooks contain products, but it is also possible to associate products with an opportunity directly.
Querying an opportunity via the API yields the following:
Array
(
[0] => Array
(
[attributes] => Array
(
[type] => Opportunity
[url] => /services/data/v33.0/sobjects/Opportunity/xxxxxxxxxxxxxxxx
)
[Id] => xxxxxxxxxxxxxxxx
[IsDeleted] =>
[AccountId] => xxxxxxxxxxxxxxxxx
[Name] => Some Name
[Description] =>
[StageName] => Closed Won
[Amount] => 650
[Probability] => 100
[CloseDate] => 2012-04-12
[Type] => New Business
[NextStep] => A string
[LeadSource] => something
[IsClosed] => 1
[IsWon] => 1
[ForecastCategory] => Closed
[ForecastCategoryName] => Closed
[CampaignId] =>
[HasOpportunityLineItem] => 1
[Pricebook2Id] => xxxxxxxxxxxxxxxxxxxxx
[OwnerId] => xxxxxxxxxxxxxxxxxxx
[CreatedDate] => 2012-12-30T20:17:35.000+0000
[CreatedById] => xxxxxxxxxxxxxxxxxxxxxxxxxxx
[LastModifiedDate] => 2015-05-22T15:20:18.000+0000
[LastModifiedById] => xxxxxxxxxxxxxxxxxxxxxxxx
[SystemModstamp] => 2015-05-22T15:20:18.000+0000
[LastActivityDate] =>
[FiscalQuarter] => 1
[FiscalYear] => 2015
[Fiscal] => 2015 1
[LastViewedDate] => 2015-06-03T14:38:03.000+0000
[LastReferencedDate] => 2015-06-03T14:38:03.000+0000
[SyncedQuoteId] =>
[Type_of_Deal__c] => Monthly Contract Count
[Number_of_Contracts__c] => 999
[Fee_Per_Contract__c] => 999
[Installation_Fee__c] =>
[Roof_Top_Fee__c] =>
[LID__LinkedIn_Company_Id__c] =>
[inclusion_type__c] => inclusion type
[Total_Contract_Term__c] => 999
[Monthly_Value_of_Fee_Per_Contract__c] => 999
[Total_Value_of_Fee_Per_Contract__c] => 999
[Total_Value_of_Roof_Top_Fee__c] => 0
[Monthly_Fidels_Revenue__c] => 999
[Total_Value_of_Deal__c] => 999
[Number_of_Roof_Tops__c] =>
[Monthly_Value_of_Roof_Top_Fee__c] => 0
[Installation_Date__c] => 2012-01-01
[Reason_if_Lost__c] =>
[Total_Monthly_Revenue__c] => 999
[Existing_Agency__c] => Service Group
[Number_of_Contracts_in_Last_Batch__c] => 999
[Agent_Name__c] => John Smith
[Total_Value_of_Agency_Revenue__c] => 9999
[Contract_Start_Date__c] => 2012-01-01
[Batch_Received__c] => Yes
[Administrator__c] =>
[Per_Contract__c] => 999
[Integration_type__c] =>
[Last_Batch_ID__c] =>
[Last_Batch_Date__c] =>
)
)
From which you can see that no Product2 data is available. There is however, a Pricebook2Id. One might assume that querying that specific pricebook would yield information on which products are associated with it. However, querying a specific pricebook yields the following:
Array
(
[0] => Array
(
[attributes] => Array
(
[type] => Pricebook2
[url] => /services/data/v33.0/sobjects/Pricebook2/xxxxxxxxxxxx
)
[Id] => xxxxxxxxxxxxxxxxxxxx
[IsDeleted] =>
[Name] => Company Price Book
[CreatedDate] => 2011-11-14T18:36:23.000+0000
[CreatedById] => xxxxxxxxxxxxxxxxxxx
[LastModifiedDate] => 2011-11-14T18:36:23.000+0000
[LastModifiedById] => xxxxxxxxxxxxxxxxxxxxxxx
[SystemModstamp] => 2011-11-14T18:36:23.000+0000
[LastViewedDate] => 2015-06-04T19:41:20.000+0000
[LastReferencedDate] => 2015-06-04T19:41:20.000+0000
[IsActive] => 1
[Description] =>
[IsStandard] =>
)
)
As you can see, no information about products is available from the pricebook. So my question is:
How do I determine which products are associated with opportunities using the Salesforce Force.com REST API?
There is an object called 'Opportunity Product'. you need to get that object as well and link the proper opportunity to product.
It's a many to many relation and not one to many so more than one product might be related to each opportunity and vise versa.

Drupal 7, iPhone image orientation messed up - no exif information

So, I have been losing my mind with this for two days now. I have a site built on Drupal 7.
The issue I have is that when my site users upload images from iPhone or iPad (both through ckeditor AND account profile images uploaded through forms) images end up being turned upside down.
I have gone as far as writing independent php to read exif data of images and detect the problem when I noticed a bizarre issue. images DO have exif information when not in drupal and it seems like they lose exif information once uploaded to drupal.
I use this code to read exif information
$full_filename ='image.jpg';
$exif = exif_read_data($full_filename);
print "<pre>";
print_r($exif);
print "<pre>";
This is a result read from an image that was not uploaded to drupal
Array
(
[FileName] => image4.jpg
[FileDateTime] => 1372430458
[FileSize] => 1568098
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF
[COMPUTED] => Array
(
[html] => width="2592" height="1936"
[Height] => 1936
[Width] => 2592
[IsColor] => 1
[ByteOrderMotorola] => 1
[ApertureFNumber] => f/2.8
[Thumbnail.FileType] => 2
[Thumbnail.MimeType] => image/jpeg
)
[Make] => Apple
[Model] => iPhone 4
[Orientation] => 6
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[Software] => 5.1.1
[DateTime] => 2013:06:28 09:18:53
[YCbCrPositioning] => 1
[Exif_IFD_Pointer] => 192
[THUMBNAIL] => Array
(
[Compression] => 6
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[JPEGInterchangeFormat] => 676
[JPEGInterchangeFormatLength] => 8886
)
[ExposureTime] => 1/24
[FNumber] => 14/5
[ExposureProgram] => 2
[ISOSpeedRatings] => 80
[ExifVersion] => 0221
[DateTimeOriginal] => 2013:06:28 09:18:53
[DateTimeDigitized] => 2013:06:28 09:18:53
[ComponentsConfiguration] =>
[ShutterSpeedValue] => 21632/4717
[ApertureValue] => 4281/1441
[BrightnessValue] => 94810/26881
[MeteringMode] => 5
[Flash] => 24
[FocalLength] => 77/20
[SubjectLocation] => Array
(
[0] => 1295
[1] => 967
[2] => 699
[3] => 696
)
[FlashPixVersion] => 0100
[ColorSpace] => 1
[ExifImageWidth] => 2592
[ExifImageLength] => 1936
[SensingMethod] => 2
[ExposureMode] => 0
[WhiteBalance] => 0
[SceneCaptureType] => 0
[Sharpness] => 2
)
and this is information from an image uploaded to drupal
Array
(
[FileName] => image3.jpg
[FileDateTime] => 1372355645
[FileSize] => 75670
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => COMMENT
[COMPUTED] => Array
(
[html] => width="1024" height="765"
[Height] => 765
[Width] => 1024
[IsColor] => 1
)
[COMMENT] => Array
(
[0] => CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 75
)
)
Is it possible that drupal has something to do with this. The GD toolkit?
I tried using imagecache autorotate and it rotates images not uploaded from iphone but no luck with ipad or iphone ones.
I am unsure how to go about this to begin with. All help is welcome.
You are not seeing things.
iPhone/Pad strip the EXIF info when they send the image.
Image upload from iphone strips exif data
The EXIF Custom Module may be of help.
https://drupal.org/project/exif_custom
So might ImageCache Actions
https://drupal.org/project/imagecache_actions

Search in multiple array in mongodb

I want to Search a value in an array Like
`[_id] => MongoId Object (
[$id] => 511f4ce622efc34f15000001
)
[metadata] => Array (
[filename] => 6410-funny_face.gif
[parrent] => myfolder/newfolder2
[user] => Array ( >>>>>>>> i need to fetch all users
[root] => 7
[admin] => 7
[user] => 0
)
[group] => Array (
[23] => 2
)
)
[filename] => 6410-funny_face.gif
[uploadDate] => MongoDate Object (
[sec] => 1361005798
[usec] => 799000
)
[length] => 3083
[chunkSize] => 262144
[md5] => eb3846f78f461165e5bf59a05707edd1`
I need to find the user's key and value in PHP or MongoShell
im using db.collection.find(array(metadata.filename: 6410-funny_face.gif)); gives the correct answer but while in finding db.collection.find(array(metadata.user: array(7)));
db.collection.find({"metadata.user.root":7})
This should work if I understand your question.