Handle post attachments Facebook API SDK 4 - facebook

Friend, I can not handle the data that return the call. How can I interact with the data, specifically with attachments. the complete result of calling this the link: http://pastebin.com/fLjV0Zu2
I'm using the conversion method for array, but it seems that this method does not interact at all levels of the object. So I can not reach the data attachments to handle.
$graphObject = $response->getGraphObject()->asArray();
$media = $graphObject->getProperty('attachments')->asArray();
print_r($media);
Result:
Array
(
[0] => stdClass Object
(
[subattachments] => stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[media] => stdClass Object
(
[image] => stdClass Object
(
[height] => 483
[src] => https://scontent-a.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/s720x720/10891987_811524088885970_7055896286836804482_n.jpg?oh=895cce48d5da3e59b374fad2f7ec8f69&oe=55297847
[width] => 720
)
)
[target] => stdClass Object
(
[id] => 811524088885970
[url] => https://www.facebook.com/photo.php?fbid=811524088885970&set=gm.767232516689804&type=1
)
[type] => photo
[url] => https://www.facebook.com/photo.php?fbid=811524088885970&set=gm.767232516689804&type=1
)
[1] => stdClass Object
(
[media] => stdClass Object
(
[image] => stdClass Object
(
[height] => 404
[src] => https://scontent-a.xx.fbcdn.net/hphotos-xaf1/v/t1.0-9/s720x720/10885099_811524235552622_234704175575422999_n.jpg?oh=d94c5f69852665adb5a8bae2217cc900&oe=552A30F4
[width] => 720
)
)
[target] => stdClass Object
(
[id] => 811524235552622
[url] => https://www.facebook.com/photo.php?fbid=811524235552622&set=gm.767232516689804&type=1
)
[type] => photo
[url] => https://www.facebook.com/photo.php?fbid=811524235552622&set=gm.767232516689804&type=1
)
[2] => stdClass Object
(
[media] => stdClass Object
(
[image] => stdClass Object
(
[height] => 404
[src] => https://scontent-b.xx.fbcdn.net/hphotos-xap1/v/t1.0-9/s720x720/10898031_811524285552617_7673546158326216312_n.jpg?oh=3376e9140822a7a79904f58f30214c5d&oe=552D6772
[width] => 720
)
)
[target] => stdClass Object
(
[id] => 811524285552617
[url] => https://www.facebook.com/photo.php?fbid=811524285552617&set=gm.767232516689804&type=1
)
[type] => photo
[url] => https://www.facebook.com/photo.php?fbid=811524285552617&set=gm.767232516689804&type=1
)
)
)
[target] => stdClass Object
(
[id] => 767232516689804
[url] => https://www.facebook.com/media/set/?set=pcb.767232516689804&type=1
)
[title] => Photos from Conceicao Fernandes's post
[type] => album
[url] => https://www.facebook.com/media/set/?set=pcb.767232516689804&type=1
)
)

For those who have the same problem. Or rather doubt.
The friend WizKid cleared my ideas.
Even using the correct method to convert the result of GraphObject using Facebook PHP SDK4, calling asArray(); to access the data, I used the form below with success.
$media = $graphObject->getProperty('attachments')->asArray();
$media[0]->subattachments->data;
To interact with the data I'm using foreach()
$data = $media[0]->subattachments->data;
foreach($data as $k => $v) {
//Here you interacted with the data
}

Related

Append filles as an array to formData

I am trying to iterate over list elements and for each elements retrive the file from an input. I can do this just find using the bellow code, but what I would like to do is have each file under a common array.
I've been trying different things, with creating an array and appending it first to the form Data, and then appending each item, but I couldn't get to ge the wanted structure.
This is what I have:
$('.noticeboard-li').each(function (index, item) {
if($(this).find('.custom-file-input')[0].files[0]) {
formData.append('noticeboardFiles'+index, $(this).find('.custom-file-input')[0].files[0]);
}
});
Output:
Array
(
[noticeboardFiles0] => Array
(
[name] => pic_1.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpdv5Uz1
[error] => 0
[size] => 47542
)
[noticeboardFiles1] => Array
(
[name] => pic_2.png
[type] => image/png
[tmp_name] => /tmp/phpEKCy6M
[error] => 0
[size] => 47542
)
)
This is how I would like the structure:
Array
(
[noticeboardFiles] => Array(
[0] => Array
(
[name] => pic_1.jpg
[type] => image/jpeg
[tmp_name] => /tmp/phpdv5Uz1
[error] => 0
[size] => 47542
)
[1] => Array
(
[name] => pic_2.png
[type] => image/png
[tmp_name] => /tmp/phpEKCy6M
[error] => 0
[size] => 47542
)
)
)

write mongodb driver query with php fetch records from embedded array

Filter item from records array it should only return two items because records.score = 100 having only two items instead this it return me all the records. Can you please help on this thanks.
I have multiple records wherein I would like to fetch only filter records. where I am doing mistake please guide and suggest.
stdClass Object
(
[_id] => e5s65d5e5s65d5s65d44f12
[records] => Array
(
[0] => stdClass Object
(
[date] => MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1609923848000
)
[score] => 100
[country] => US
[state] => Connecticut
[city] => Berlin
)
[1] => stdClass Object
(
[date] => MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1609923501000
)
[score] => 100
[country] => US
[state] => California
[city] => Barstow
)
[2] => stdClass Object
(
[date] => MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1609923157000
)
[score] => 145
[country] => US
[state] => Alabama
[city] => Alexander City
)
[3] => stdClass Object
(
[date] => MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1609923108000
)
[score] => 150
[country] => US
[state] => Alaska
[city] => Anchorage
)
)
)
$mng = new MongoDB\Driver\Manager("mongoatlas/");
$filter = ['records.score' => '100'];
$query = new MongoDB\Driver\Query($filter, ['sort' => ['records.date' => 1], 'limit' => 6]);
$rows = $mng->executeQuery("db.table", $query);
expected result should be only two item whose state is Connecticut, California because their score are 100
Try this one
$command = new MongoDB\Driver\Command([
'aggregate' => 'collection',
'pipeline' => [
['$unwind' => '$records'],
['$match' => ['records.score' => '100']],
['$sort' => ['records.date' => 1]],
['$limit' => 6]
],
'cursor' => new stdClass,
]);
$cursor = $mng->executeCommand('database', $command);

Dot notation in MongoDB InsertOne

While performing InsertOne in MongoDB (4.0.5) from PHP I get the following exception:
[0] Detected unsupported PHP type for field path "context.trace.1.args.2": 7
According to the MongoDB documentation one is allowed to use dot notation in update commands. The doc however talks about this fact with $set as context.
It seems to me that a simple Update does not allow for dot notation. (just guessing)
Can someone explain the nuance/edge cases here?
===== follow up on request:
The document is created by Monolog.
And the document used in InsertOne looks like the following:
Array
(
[message] => file_get_contents( ...obfuscated... ): failed to open stream: Connection timed out
[context] => Array
(
[code] => 2
[file] => ...obfuscated...
[line] => 127
[trace] => Array
(
[0] => Array
(
[function] => handleError
[class] => Whoops\Run
[type] => ->
...obfuscated...
)
[1] => Array
(
[function] => file_get_contents
[args] => Array
(
[0] => https:// ...obfuscated...
[1] =>
[2] => 0
)
)
[2] => Array
(
[file] => ...obfuscated... .php
[line] => 127
[function] => file_get_contents
[args] => Array
(
[0] => https:// ...obfuscated...
)
)
[3] => Array
(
[file] => ...obfuscated... .php
[line] => 91
[args] => Array
(
[0] => ...obfuscated... .php
)
[function] => require_once
)
)
[notThrown] => 1
[type] => Whoops\Exception\ErrorException
)
[level] => 500
[level_name] => CRITICAL
[channel] => ...obfuscated...
[datetime] => MongoDB\BSON\UTCDateTime Object
(
[milliseconds] => 1551951362000
)
[extra] => Array
(
[cli] => Array
(
[user] => ...obfuscated...
[script] => ...obfuscated... .php
[argv] => Array
(
[0] => ...obfuscated...
)
)
[server_name] => ...obfuscated...
[server_ip] => ...obfuscated...
[process_id] => 3273
[memory_peak_usage] => 5.75 MB
[memory_usage] => 5.75 MB
[git] => Array
(
[ ...obfuscated... ] => Array
(
[branch] => ...obfuscated...
[commit] => ...obfuscated...
)
[publisher] => Array
(
[branch] => ...obfuscated...
[commit] => ...obfuscated...
)
)
)
[server_name] => ...obfuscated...
[_id] => MongoDB\BSON\ObjectId Object
(
[oid] => 5c81e6029caba40cc96bd831
)
)
I suspect Neil Lunn already answers the question.
But now I wonder whether this is a shortcoming of Monolog or not. And what approach to take to solve this issue.

Adaptive payment paypal credentials

I am working with Project theme in word Press..I this theme i am using Adaptive payment method for paypal gateway..But i am unable to do..Can any one please help me to complete this task. I got an array see below for array..
I am using Sandbox details
Array
(
[0] => Array
(
[name] => ns3:FaultMessage
[attributes] => Array
(
[xmlns:ns3] => http://svcs.paypal.com/types/common
[xmlns:ns2] => http://svcs.paypal.com/types/ap
)
[0] => Array
(
[name] => responseEnvelope
[0] => Array
(
[name] => timestamp
[value] => 2015-10-12T02:10:03.535-07:00
)
[1] => Array
(
[name] => ack
[value] => Failure
)
[2] => Array
(
[name] => correlationId
[value] => a7b08f9b701fa
)
[3] => Array
(
[name] => build
[value] => 17820627
)
)
[1] => Array
(
[name] => error
[0] => Array
(
[name] => errorId
[value] => 520009
)
[1] => Array
(
[name] => domain
[value] => PLATFORM
)
[2] => Array
(
[name] => subdomain
[value] => Application
)
[3] => Array
(
[name] => severity
[value] => Error
)
[4] => Array
(
[name] => category
[value] => Application
)
[5] => Array
(
[name] => message
[value] => Account Account not found. Unilateral receiver not allowed in chained payment is restricted
)
[6] => Array
(
[name] => parameter
[value] => Account not found. Unilateral receiver not allowed in chained payment
)
)
)
)

Zend_Db Enum Values

I find this solution
$metadata = $result->getTable()->info('metadata');
echo $metadata['Continent']['DATA_TYPE'];
Hi,
I want to get enum values in Zend_Db.
My Code:
$select = $this->select();
$result = $select->fetchAll();
print_r($result->getTable());
Output:
Example Object
(
[_name] => country
[query] => Zend_Db_Table_Select Object
(
[_info:protected] => Array
(
[schema] =>
[name] => country
[cols] => Array
(
[0] => Code
[1] => Continent
)
[primary] => Array
(
[1] => Code
)
[metadata] => Array
(
[Continent] => Array
(
[SCHEMA_NAME] =>
[TABLE_NAME] => country
[COLUMN_NAME] => Continent
[COLUMN_POSITION] => 3
[DATA_TYPE] => enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America')
[DEFAULT] => Asia
[NULLABLE] =>
[LENGTH] =>
[SCALE] =>
[PRECISION] =>
[UNSIGNED] =>
[PRIMARY] =>
[PRIMARY_POSITION] =>
[IDENTITY] =>
)
I see enum values in data_type but i don't get this values. How can get data_type?
I find this solution
$metadata = $result->getTable()->info('metadata');
echo $metadata['Continent']['DATA_TYPE'];