I'm trying to query FB for a Page Stream using FQL in PHP, and I get all the data except impressions. The FB_ACCESS_TOKEN used is the OAuth token for my FB App, where I have granted the following scope: offline_access,manage_pages,email,read_insights,sms,publish_stream
Code example:
$this->fb->api(array(
"method" => "fql.multiquery",
"queries" => json_encode(array(
"post" => "SELECT post_id, source_id, updated_time, created_time, actor_id,
message, attachment, impressions, likes, privacy,
permalink, comments
FROM stream WHERE source_id='".$source_id."'
AND created_time > '".$date_updated."'",
"comment" => "SELECT post_id, fromid, time, text, id, likes, object_id
FROM comment WHERE post_id IN (SELECT post_id FROM #post)
AND time> '".$date_updated."'"
)), access_token" => FB_ACCESS_TOKEN
));
Here is the example output:
[...]
[0] => Array(
[post_id] => 107112482661088_236459409726394
[source_id] => 107112482661088
[updated_time] => 1312884237
[created_time] => 1312884237
[actor_id] => 608795063
[message] => funker jo ikke detta nå da :( får ikke spilt i det hele tatt :#
[attachment] => Array(
[description] =>
)
[impressions] =>
[likes] => Array(
[href] => http://www.facebook.com/browse/?type=likes&id=236459409726394
[count] => 0
[sample] => Array()
[friends] => Array()
[user_likes] =>
[can_like] =>
)
[privacy] => Array(
[value] =>
)
[permalink] => http://www.facebook.com/hacktheplanet.no/posts/236459409726394
[comments] => Array(
[can_remove] =>
[can_post] =>
[count] => 0
[comment_list] => Array()
)
)
[...]
Any suggestions or reasons why I don't get the impression data?
Have you tried this query for a post that is several days old?
Facebook Insights seems to usually be 24 to 48 hours behind and I believe that is the source of the impressions value.
To validate, I ran your FQL query for a post created today on a page that I have read_insights permissions for. The result for "impressions" was null (like in your example).
I then ran the same query for a post three days ago and the number of impressions was present.
Related
I have two arrays:
(
[lineCode] => C
[serviceRequest] => Ext, Warr auth.#19091100102 for $650.64 to be paid by c/card(fax#817-785-6700). Cust owes balance
[skillCode] => 90SB
[opCode] => 90SB
[jobType] => CUSTOMER
[techNo] =>
[lineStatus] => C
)
(
[id] => 755350
[rid] => 252178
[lineCode] => C
[serviceRequest] => Ext, Warr auth.#19091100102 for $650.64 to be paid by c/card(fax#817-785-6700). Cust owes balance
[skillCode] => 90SB
[opCode] => 90SB
[jobType] => CUSTOMER
[techNo] =>
[lineStatus] => W
[timeA] => 1575497139
[timeC] => 0
)
When i perform $diff = array_diff($arry1, $arry2);, it does not find the lineStatus to be different. Could it be because of service Request line with special characters? Although as a test, I set both lines to blanks, and it still did not see the difference.
Any help would be great. Stumped for the day.
UPDATE w/ MORE INFO
As this is part of a larger loop through mulitple arrays, the diff check before this one above is below:
$arry1= Array
(
[lineCode] => B
[serviceRequest] =>
[skillCode] => 15
[opCode] => 15
[jobType] => CUSTOMER
[techNo] => A05
[lineStatus] => C
)
$arry2= Array
(
[id] => 755362
[rid] => 252184
[lineCode] => B
[serviceRequest] =>
[skillCode] => 15
[opCode] => 15
[jobType] => CUSTOMER
[techNo] => A05
[lineStatus] => W
[timeA] => 1575504138
[timeC] => 0
)
$diff= Array
(
[lineStatus] => C
)
the code for the diff is $diff=array_diff($arry1,$arry2);
If it works correctly for this one, why would it not for the next.
Why does it not find it the way you originally did it...?
array_diff() does not care about key-value combinations, it only compares the values in the different arrays that are compared.
To better understand what's happening: if in your updated data you introduce an array element [dummy] => "C" into $arry2 you will no longer get [lineStatus] => "C" returned into $diff. As the value C is now found in both $arry1 and $arry2.
Have a look at this demo
I am using PHP WhatsApp Library. As per instructions I got my login and password. Upon using I am getting error:
] Logging in as 'SmartConnect Agent' (12334) tx <stream:features></stream:features>
tx <auth user="12334" mechanism="WAUTH-2"></auth>
rx <from s.whatsapp.net=""></from>
rx <stream:features></stream:features>
rx <challenge>fafa1216bdf3c4c4528e10d80b29c6026493682d</challenge>
tx <response>19d8120136e5897f38fe0904e54611cd8510f029bdd97f077f460faba15bc68cd0644e87ebf4b8288a143dc1914cb61bf4bfa2f17e0d7187afa8fcd18e69bb2b75d4f2da549c3d3c3facedd808bc</response>
rx <failure>
rx <not-authorized></not-authorized>
rx </failure>
Upon running blockchecker.php I get. Even same thing when I am retying to register by using registerTool.php
Wrong identity.
Array
(
[cc] => 92
[in] => 1234566
[lg] => en
[lc] => PK
[id] => >zv?+?????w!l?v?5b?
[mistyped] => 6
[network_radio_type] => 1
[simnum] => 1
[s] =>
[copiedrc] => 1
[hasinrc] => 1
[rcmatch] => 1
[pid] => 579
[extexist] => 1
[extstate] => 1
)
stdClass Object
(
[status] => fail
[reason] => incorrect
[sms_length] => 6
[voice_length] => 6
[sms_wait] => 0
[voice_wait] => 0
)
It generated multiple IDentity file of a same number. I removed all and it generated new password.
Im doing a search system and Im having some problems.
I need to search in two tables (news and pages), I already had sucess doing my search system for just one table, but for two tables its not easy to do.
I already use a select statment with two tables using UNION because I want to show number of search results, that is number of returned rows of my first sql statment.
But now I need to do a select statment that allows me to acess all fields of my news table and all fields of my pages table.
I need to acess in my news table this fields: id, title, content, link, date, nViews
I need to acess in my pages table this fields: id, title, content, link
Im trying to do this also with UNION, but in this case Im not having any row returning.
Do you see what I have wrong in my code?
<?php
//first I get my $search keyword
$search = $url[1];
$pdo = connecting();
//then I want to show number of returned rows for keyword searched
$readALL = $pdo->prepare("SELECT title,content FROM news WHERE title LIKE ? OR content LIKE ?
UNION SELECT title,content FROM pages WHERE title LIKE ? OR content like ?");
$readALL->bindValue(1,"%$search%", PDO::PARAM_STR);
$readALL->bindValue(2,"%$search%", PDO::PARAM_STR);
$readALL->bindValue(3,"%$search%", PDO::PARAM_STR);
$readALL->bindValue(4,"%$search%", PDO::PARAM_STR);
$readALL->execute();
//I show number of returned rows
echo '<p>Your search keyword returned <strong>'.$readALL->rowCount().'</strong> results!</p>';
//If dont return any rows I show a error message
if($readALL->rowCount() <=0){
echo 'Sorry but we didnt found any result for your keyword search.';
}
else{
//If return rows I want to show, if it is a page result I want to show title and link that I have in my page table
//if it is a news result I want to show title and link that I have in my news table and also date of news
echo '<ul class="searchlist">';
$readALL2 = $pdo->prepare("SELECT * FROM news WHERE status = ? AND title LIKE ? OR content LIKE ? LIMIT 0,4
UNION SELECT * FROM pages where title LIKE ? OR content LIKE ? LIMIT 0,4");
$readALL2->bindValue(1, '1');
$readALL2->bindValue(2, "%$search%", PDO::PARAM_STR);
$readALL2->bindValue(3, "%$search%", PDO::PARAM_STR);
$readALL2->bindValue(4, "%$search%", PDO::PARAM_STR);
$readALL2->execute();
while ($result = $readALL2->fetch(PDO::FETCH_ASSOC)){
echo '<li>';
echo '<img src="'.BASE.'/uploads/news/'.$result['thumb'].'"/>';
echo ''.$result['title'].'';
//if it is a news result I also want to show data on my list
//echo '<span id="date">'.$result['data'].'</span>';
echo '</li>';
}
echo ' </ul>';
//but how can I do my select statement to have access to my news table fields and my page table fields??
}
?>
This is my news table:
This is my pages table:
When I search on my form for keyword "doc" I get this:
Your are searching for keyword: "doc"
your search returned 2 results!
Array ( [id_news] => 472 [thumb] => 2014/07/title-of-news-11405372264.png [title] => Documents [content] => Link 1, Link 2 [ofte] => 2014-07-14 23:11:04 [views] => 0 [author] => 1 [category] => 116 [status] => 1 [id] => 1 [link] => documents ) image of news Documents
Array ( [id_news] => 473 [thumb] => 2014/07/title-of-news-21405372282.png [title] => Documents [content] => Link 1, Link 2 [ofte] => 2014-07-14 23:11:22 [views] => 0 [author] => 1 [category] => 115 [status] => 1 [id] => 1 [link] => documents ) image of news Documents
Array ( [id_news] => 472 [thumb] => 2014/07/title-of-news-11405372264.png [title] => About [content] => we are a company... [ofte] => 2014-07-14 23:11:04 [views] => 0 [author] => 1 [category] => 116 [status] => 1 [id] => 2 [link] => about ) image of news About
Array ( [id_news] => 473 [thumb] => 2014/07/title-of-news-21405372282.png [title] => About [content] => we are a company... [ofte] => 2014-07-14 23:11:22 [views] => 0 [author] => 1 [category] => 115 [status] => 1 [id] => 2 [link] => about ) image of news About
Array ( [id_news] => 472 [thumb] => 2014/07/title-of-news-11405372264.png [title] => Contacts [content] => Email: test#email.com [ofte] => 2014-07-14 23:11:04 [views] => 0 [author] => 1 [category] => 116 [status] => 1 [id] => 3 [link] => contacts ) image of news Contacts
Array ( [id_news] => 473 [thumb] => 2014/07/title-of-news-21405372282.png [title] => Contacts [content] => Email: test#email.com [ofte] => 2014-07-14 23:11:22 [views] => 0 [author] => 1 [category] => 115 [status] => 1 [id] => 3 [link] => contacts ) image of news Contacts
To query 2 tables, and have the result set contain columns from both tables:
SELECT n.id, n.status, n.views, p.id, p.title
FROM news n, pages p
WHERE n.status = ?
AND p.title = ?
...
To simplify my answer I have omitted most of your required columns, but you simply add more to the select statement. Of course, you can always use
SELECT n.*, p.*
To select all columns from both tables.
Update:
For your specific scenario, try:
SELECT n.*, p.*
FROM news n, pages p
WHERE n.title LIKE ?
OR n.content LIKE ?
OR p.title LIKE ?
OR p.content LIKE ?
I'm in a bind with a deadline and I cannot seem to figure this out.
I am trying to query the table to get the values for the corresponding max shipdate. My query is below. This is for Fox Pro using an ODBC driver.
SELECT
so1.sono,
so1.custno,
so1.item,
so1.shipdate as last_shipdate,
so1.price as last_price
FROM sotran01 so1
INNER JOIN (
SELECT
custno,
item,
MAX(shipdate) as last_shipdate
FROM sotran01
WHERE shipdate >= {d'2013-05-23'}
AND shipdate <= {d'2014-05-23'}
GROUP BY custno, item
) so2 ON (so1.custno = so2.custno AND so1.item = so2.item AND so1.shipdate = so2.last_shipdate)
WHERE so1.item IN (
SELECT item
FROM arpric01
)
ORDER BY so1.custno, so1.item, so1.shipdate
This is what I get (using ADOdb):
ADODB_vfp Object
(
[databaseType] => vfp
[fmtDate] => {^Y-m-d}
[fmtTimeStamp] => {^Y-m-d, h:i:sA}
[replaceQuote] => '+chr(39)+'
[true] => .T.
[false] => .F.
[hasTop] => top
[_bindInputArray] =>
[sysTimeStamp] => datetime()
[sysDate] => date()
[ansiOuter] => 1
[hasTransactions] =>
[curmode] =>
[dataProvider] => odbc
[hasAffectedRows] => 1
[binmode] => 1
[useFetchArray] =>
[_genSeqSQL] => create table %s (id integer)
[_autocommit] => 1
[_haserrorfunctions] => 1
[_has_stupid_odbc_fetch_api_change] => 1
[_lastAffectedRows] => 0
[uCaseTables] => 1
[_dropSeqSQL] => drop table %s
[database] =>
[host] => DRIVER={Microsoft Visual FoxPro Driver};SOURCETYPE=dbf;SOURCEDB=C:\Sites\hub.fieldfresh.dev\_cache\VP10\PRAXIS\;EXCLUSIVE=NO;
[user] =>
[password] =>
[debug] =>
[maxblobsize] => 262144
[concat_operator] => +
[substr] => substr
[length] => length
[random] => rand()
[upperCase] => upper
[nameQuote] => "
[charSet] =>
[metaDatabasesSQL] =>
[metaTablesSQL] =>
[uniqueOrderBy] =>
[emptyDate] =>
[emptyTimeStamp] =>
[lastInsID] =>
[hasInsertID] =>
[hasLimit] =>
[readOnly] =>
[hasMoveFirst] =>
[hasGenID] =>
[genID] => 0
[raiseErrorFn] =>
[isoDates] =>
[cacheSecs] => 3600
[memCache] =>
[memCacheHost] =>
[memCachePort] => 11211
[memCacheCompress] =>
[sysUTimeStamp] =>
[arrayClass] => ADORecordSet_array
[noNullStrings] =>
[numCacheHits] => 0
[numCacheMisses] => 0
[pageExecuteCountRows] => 1
[uniqueSort] =>
[leftOuter] =>
[rightOuter] =>
[autoRollback] =>
[poorAffectedRows] =>
[fnExecute] =>
[fnCacheExecute] =>
[blobEncodeType] =>
[rsPrefix] => ADORecordSet_
[autoCommit] => 1
[transOff] => 0
[transCnt] => 0
[fetchMode] => 2
[null2null] => null
[bulkBind] =>
[_oldRaiseFn] =>
[_transOK] =>
[_connectionID] => Resource id #8
[_errorMsg] => [Microsoft][ODBC Visual FoxPro Driver]Syntax error.
[_errorCode] => 37000
[_queryID] =>
[_isPersistentConnection] =>
[_evalAll] =>
[_affected] =>
[_logsql] =>
[_transmode] =>
[_error] =>
)
The error doesn't say much. I can copy and paste the code into MySQL and it runs fine and returns what I expect. Hopefully another set of eyes, with more Fox Pro experience, can see what the issue is here.
Thanks for any assistance.
Your subquery is incorrect. This is the subquery:
INNER JOIN (
SELECT custno, item, MAX(shipdate) as last_shipdate
FROM sotran01
WHERE shipdate >= {d'2013-05-23'}
AND shipdate <= {d'2014-05-23'}
GROUP BY custno, item, last_shipdate
-------------------------------^
)
That is an aggregation column. Remove it:
INNER JOIN (
SELECT custno, item, MAX(shipdate) as last_shipdate
FROM sotran01
WHERE shipdate >= {d'2013-05-23'}
AND shipdate <= {d'2014-05-23'}
GROUP BY custno, item
)
I know how to retrieve the comments for each posts, but now I'm trying to do my own system 'reply to'. When someone replying, I store the comment id as reply_id in new comment.
$sql = 'SELECT cid, cname, user_uid, reply_id,
published, content, avatar
FROM comments, users
WHERE report < 3 AND (uid = user_uid AND post_pid='.$id.')
OR ( user_uid ="_'.$id.'" AND post_pid='.$id.')';
this request return me this list of comments:
Array
(
[0] => stdClass Object
(
[cid] => 101
[cname] => ramzan
[user_uid] => 1
[reply_id] => 100
[published] => 2013-12-08 01:44:56
[content] => why?
[avatar] => users/anonyme.png
)
[1] => stdClass Object
...
but I want to get something like this :
Array
(
[0] => stdClass Object
(
[cid] => 101
[cname] => ramzan
[user_uid] => 1
[reply_id] => array() // the reply if exist
[published] => 2013-12-08 01:44:56
[content] => why?
[avatar] => users/anonyme.png
)
maybe this is a bad idea to do like this, but I don't know how to do otherwise!!!
maybe someone can help this, I resolved my problem like this :
lvl1, lvl2 have to be declare as null, only set the value of field when someone reply to a comment
...SELECT field FROM table where ...
ORDER BY COALESCE (lvl1, lvl2, id ), lvl1, lvl2, id
...
Thank you,
Best regards