I use getUserPhotos to get profile photos. What is the main standard source that I should use for html src attribute? (I searched even in telegram's docs, but didn't get the solution.)
A part of my result (type is photos.Photos):
Array
(
[_] => photos.photosSlice
[count] => 14
[photos] => Array
(
[0] => Array
(
[_] => photo
[has_stickers] =>
[id] => 195744071274310414
[access_hash] => -5116812755800708610
[date] => 1472714208
[sizes] => Array
(
[0] => Array
(
[_] => photoSize
[type] => a
[location] => Array
(
[_] => fileLocation
[dc_id] => 4
[volume_id] => 425426808
[local_id] => 100105
[secret] => -7781982930425156181
)
[w] => 160
[h] => 160
[size] => 11694
)
...
What you need to do is use the following method to download your file or picture:
upload.getFile#e3a6cfb5 location:InputFileLocation offset:int limit:int = upload.File;
Where InputFileLocation is defined below, and may be obtained from PhotoSize.location in your question above:
inputFileLocation#14637196 volume_id:long local_id:int secret:long = InputFileLocation;
more details on file download here: https://core.telegram.org/api/files#downloading-files
Related
so my variable contains an array of objects. each object is like this
Array
(
[0] => CustomAudienceBean Object
(
[limit:protected] =>
[account_id:protected] => 2342354235235
[approximate_account:protected] =>
[data_source:protected] => stdClass Object
(
[type] => SEED_BASED
[sub_type] => ENGAGEMENT_EVENT_USERS
[creation_params] => []
)
[type:protected] =>
[sub_type:protected] =>
[creation_params:protected] => Array
(
)
[delivery_status:protected] => stdClass Object
(
[code] => 300
[description] => Audiences must include at least 20 people to be used for ads.
)
[code:protected] =>
[description:protected] =>
[external_event_source:protected] =>
[id:protected] => 23423asdf23423tadf23
[is_value_based:protected] =>
[lookalike_audience_ids:protected] =>
[lookalike_spec:protected] => stdClass Object
It's quite deep..
how to convert the array into a ArrayDataProvider in yii
I think there's no out of the box way. Your CustomAudienceBean object's properties are protected, so you can't access them directly. You have to extend the class if there are no public methods.
You have 2 options,
Extend CustomAudienceBean class and define a method to return all the properties you need. Then iterate your dataset and build the array for CArrayDataProvider
Extend the CArrayDataProvider and feed your array of objects. Then inside your custom ArrayDataProvider you can extract the properties from CustomAudienceBean object
I am working in a project where i have to integrate face-book graph-api. Everything is going well
but i stuck in a problem to fetch my face book friend list using /me/friends/. It return me only
those friends which has log in with my app, but i want my all friend list
$session = new FacebookSession( $session->getToken());
$friends= (new FacebookRequest( $session, 'GET', '/me/friends' ))->execute()->getGraphObject()
->asArray();
echo '<pre>' . print_r( $friends, 1 ) . '</pre>';
It return
[data] => Array
(
[0] => stdClass Object
(
[name] => Nitin Chamola
[id] => 792718557454395
)
[1] => stdClass Object
(
[name] => Ajay Aggarwal
[id] => 765446336856080
)
[2] => stdClass Object
(
[name] => Manjit Singh Jassal
[id] => 1538019986415496
)
[3] => stdClass Object
(
[name] => Sapna Thakur
[id] => 1518184435101741
)
)
[paging] => stdClass Object
(
[next] => https://graph.facebook.com/v2.2/1587893521432407/friends?access_token=CAAGPXznoOFkBAOCKznoJ4AwZBi9DhlNQYuvgn1qT1Qz3x0JE5mUT5JXOnEnhPtpcriJjoRB5K2yNW3B2L0PtJEcgy8MK3NbZB2oHeBPEeayudFSSxDDOTYUc4J3Q9zDkBqsIGcDcHyzECBtHqOM2HKRUwdOmsSRAJQ41lVWj0T1O2bH1P4ZC2Or2Gv0FuVTL7Wp2xudgGsDHyjwLvGT&limit=25&offset=25&__after_id=enc_AexVs_nuUmTOuF4B5iplPfzsuPs6vtQGx7TV_pH-cINIX2nUIvn3vdmWzNINrKx-vqDnpavxrIA_kr3aqSr6lw4k
)
[summary] => stdClass Object
(
[total_count] => 242
)
After Graph API 2 and above you can no longer do this. You can only fetch the list of those friends who use your app i,e who have given permission to your app. This has been done by fb for security reasons.
As according to the mention documentation at whoapi.com i have gone through as mention according to instruction and tried implementing the api but the variable doesn't pass from one page to other.For example i have one page which have input type and submit button then when i click submit button it should redirect to who api url and display result
http://api.whoapi.com/?domain=whoapi.com&apikey=demokey&r=blacklist
whoapi.com = name of url,demokey = key assigned by who api & blacklist = name of service of who api
guide me through the connecting protocol.
Not sure I understand the question. Using the API should be straight simple as any REST request is.
PHP example:
$domain = "whoapi.com";
$r = "blacklist";
$apikey = "demokey";
$request = "http://api.whoapi.com/?domain=$domain&r=$r&apikey=$apikey";
$output = json_decode(file_get_contents($request), true);
Resulting array with print_r($output) looks like this:
[status] => 0
[ip] => 88.198.98.181
[blacklisted] => 0
[blacklists] => Array
(
[0] => Array
(
[tracker] => invaluement.com
[blacklisted] => 0
)
[1] => Array
(
[tracker] => surbl.org
[blacklisted] => 0
)
[2] => Array
(
[tracker] => barracudacentral.org
[blacklisted] => 0
)
[3] => Array
(
[tracker] => sorbs.net
[blacklisted] => 0
)
[4] => Array
(
[tracker] => spamhaus.org
[blacklisted] => 0
)
)
Hope this helps.
I'm new to PHP and I am currently developing a small web application. Below is the test code for the DB query using PDO:
try
{
$dsn = "mysql:host=localhost;dbname=auction";
$opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
);
$pdo = new PDO($dsn, 'root', 'password', $opt);
}
catch(PDOException $e)
{
echo $e->getMessage();
}
$stmt = $pdo->query("SELECT id,username,password,name,level FROM users");
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$test = $stmt->fetchALL();
print_r($test);
The output of the said code is the following:
Array ( [0] => Array ( [id] => 1 [username] => admin [users] => Administrator [auction] => 0 )
[1] => Array ( [id] => 2 [username] => jodel [users] => Jodel Ross [auction] => 1 ) )
I am confused because, from my point of view, the above code should have given an associative array whose index are the columns of the returned result set, i.e. id, username,password,name,level. But it is not so.
Moreover, If I used PDO::FETCH_NUM, the correct number of fields and corresponding data are returned correctly as show below:
Array ( [0] => Array ( [0] => 1
[1] => admin
[2] => 21232f297a57a5a743894a0e4a801fc3
[3] => Administrator
[4] => 0 )
[1] => Array ( [0] => 2
[1] => jodel_ross
[2] => 2cdaeb5df4cf941d9c5650591cba1fdc
[3] => Jodel Ross, Jr.
[4] => 1 ) )
Please help, I need to understand why and I have search the web for answers and have not found any.
Thanks.
Development environment:
Windows 7 x64
PHP 5.3.6
Mysql 5.5
Apache 2.0.64
Zend Framework 1.11
There is still an open error with Zend Framework 1.x, PHP 5.3.x and setFetchMode() and that's the reason why it doesn't work as expected.
see http://framework.zend.com/issues/browse/ZF-10866 and http://framework.zend.com/issues/browse/ZF-3470
Please vote for closing this error or submit a patch.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I often find myself with fairly complex data that represents something that my objects will be working on. For example, in a task-list app, several objects might work with an array of tasks, each of which has attributes, temporal expressions, sub tasks and sub sub tasks, etc.
One object will collect data from web forms, standardize it into a format consumable by the class that will save them to the database, another object will pull them from the database, put them in the standard format and pass them to the display object, or the update object, etc.
The data itself can become a fairly complex series of arrays and sub arrays, representing a 'task' or list of tasks.
For example, the below might be one entry in a task list, in the format that is consumable by the various objects that will work on it. Normally, I just document this in a file somewhere with an example. However, I am thinking about the best way to add it to something like PHPDoc, or another standard doc system.
Where would you document your consumable data formats that are for many or all of the objects / methods in your app?
Array
(
[Meta] => Array
(
//etc.
)
[Sched] => Array
(
[SchedID] => 32
[OwnerID] => 2
[StatusID] => 1
[DateFirstTask] => 2011-02-28
[DateLastTask] =>
[MarginMonths] => 3
)
[TemporalExpressions] => Array
(
[0] => Array
(
[type] => dw
[TemporalExpID] => 3
[ord] => 2
[day] => 6
[month] => 4
)
[1] => Array
(
[type] => dm
[TemporalExpID] => 32
[day] => 28
[month] => 2
)
)
[Task] => Array
(
[SchedTaskID] => 32
[SchedID] => 32
[OwnerID] => 2
[UserID] => 5
[ClientID] => 9
[Title] => Close Prior Year
[Body] =>
[DueTime] =>
)
[SubTasks] => Array
(
[101] => Array
(
[SchedSubTaskID] => 101
[ParentST] =>
[RootT] => 32
[UserID] => 2
[Title] => Review Profit and Loss by Class
[Body] =>
[DueDiff] => 0
)
[102] => Array
(
[SchedSubTaskID] => 102
[ParentST] =>
[RootT] => 32
[UserID] => 2
[Title] => Review Balance Sheet
[Body] =>
[DueDiff] => 0
)
[103] => Array
(
[SchedSubTaskID] => 103
[ParentST] =>
[RootT] => 32
[UserID] => 2
[Title] => Review Current Year for Prior Year Expenses to Accrue
[Body] => Look at Journal Entries that are templates as well.
[DueDiff] => 0
)
[104] => Array
(
[SchedSubTaskID] => 104
[ParentST] =>
[RootT] => 32
[UserID] => 2
[Title] => Review Prior Year Membership from 11/1 - 12/31 to Accrue to Current Year
[Body] =>
[DueDiff] => 0
)
[105] => Array
(
[SchedSubTaskID] => 105
[ParentST] =>
[RootT] => 32
[UserID] => 2
[Title] => Enter Vacation Accrual
[Body] =>
[DueDiff] => 0
)
[106] => Array
(
[SchedSubTaskID] => 106
[ParentST] => 105
[RootT] => 32
[UserID] => 2
[Title] => Email Peter requesting Vacation Status of Employees at Year End
[Body] => We need Employee Name, Rate and Days of Vacation left to use.
We also need to know if the employee used any of the prior year's vacation.
[DueDiff] => 43
)
[107] => Array
(
[SchedSubTaskID] => 107
[ParentST] =>
[RootT] => 32
[UserID] => 2
[Title] => Grants Receivable at Year End
[Body] =>
[DueDiff] => 0
)
[108] => Array
(
[SchedSubTaskID] => 108
[ParentST] => 107
[RootT] => 32
[UserID] => 2
[Title] => Email Peter Requesting if there were and Grants Receivable at year end
[Body] =>
[DueDiff] => 43
)
)
)
I would document with and in the code that defines the data. One way to self document is to use classes with well named attributes instead of arrays or hashes when things start to become complex. Just use comments sparingly to clear up any unobvious areas. Assume that the is smarter than you and avoid comments that clutter things.