I am trying to retrieve Fb comments on a particular post. I tried to implement following method:
FbGraphResponse *fb_graph_response = [fbGraph doGraphPost1:#"3788106577940/comments" withPostVars1:[[NSDictionary alloc]initWithObjectsAndKeys:#"Hello",#"Hi", nil]];
SBJSON *parser = [[SBJSON alloc] init];
NSDictionary *facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil];
//[parser release];
//let's save the 'id' Facebook gives us so we can delete it if the user presses the 'delete /me/feed button'
self.feedPostId = (NSString *)[facebook_response objectForKey:#"id"];
NSLog(#"feedPostId, %#", feedPostId);
But i am getting the following error:
<CFBasicHash 0x6a64360 [0x1751b38]>{type = mutable dict, count = 1,
entries =>
11 : <CFString 0x6a64e30 [0x1751b38]>{contents = "error"} = <CFBasicHash 0x6a64170 [0x1751b38]>{type = mutable dict, count = 3,
entries =>
2 : <CFString 0x6a64410 [0x1751b38]>{contents = "type"} = <CFString 0x6a645f0 [0x1751b38]>{contents = "OAuthException"}
3 : <CFString 0x6a64590 [0x1751b38]>{contents = "message"} = <CFString 0x6a644f0 [0x1751b38]>{contents = "(#1705) : You cannot make blank posts. Please enter some text and try again."}
6 : <CFString 0x6a64200 [0x1751b38]>{contents = "code"} = 1705
}
}
i have accessed following permissions:
[fbGraph authenticateUserWithCallbackObject:self andSelector:#selector(fbGraphCallback)
andExtendedPermissions:#"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins,read_stream"];
Please do help.Thanks!!
Related
(I am a new developer)I have a list that I put in a viewBag to make a dropwdown in my view and I would like to add 3 elements to this list so that we can see them at the end of my dropdown. I make a timesheet for the employees and I have a dropdown of the projects that the person worked during the week and I would like to add at the end of the dropdown the 3 options "Vacancy", "Unplanned Absence", "Planned Absence" if the person has been on leave instead of working.
This is my request for the projects :
var projectAssignment = (from pa in db.ProjectAssignment
join p in db.Projects on pa.ProjectId equals p.ID
where pa.EmployeeId == EmployeeId && pa.StartDate !=null && (pa.EndDate == null || pa.EndDate >= DateTime.Now)
select new ProjectTimesheetList
{
ProjectName = p.ProjectName,
ProjectId = pa.ProjectId
});
ViewBag.ProjectTimeSHeet = projectAssignment;
This is a the modal to add my timehseet and i want to put the 3 daysoff type at the end of dropdown, so in this case after "NatureBooker"
And this is my code of my dropdown:
<select name="' + row + '_' + col + '" class="custom-select" id="tsCell_' + row + '_' + col + '" data-row="' + row + '" data-col="' + col + '">' +
'<option value="">----Select----</option>#Html.Raw(projsStr)</select>';
SOLUTION:
var projectAssignment = (from pa in db.ProjectAssignment
join p in db.Projects on pa.ProjectId equals p.ID
where pa.EmployeeId == EmployeeId && pa.StartDate !=null && (pa.EndDate == null || pa.EndDate >= DateTime.Now)
select new ProjectTimesheetList
{
ProjectName = p.ProjectName,
ProjectId = pa.ProjectId
});
List<ProjectTimesheetList> projectAssignments = projectAssignment.ToList();
projectAssignments.Add(new ProjectTimesheetList
{
ProjectName = "Vacancy",
ProjectId = -1,
});
projectAssignments.Add(new ProjectTimesheetList
{
ProjectName = "Unplanned Absence",
ProjectId = -2,
});
projectAssignments.Add(new ProjectTimesheetList
{
ProjectName = "Planned Absence",
ProjectId = -3,
});
ViewBag.ProjectTimeSHeet = projectAssignments;
And the result:
Still not clear what exactly you want, but if my guess is right you probably want to add "fake" projects to the enumerable you're binding to (not a list, by the way).
As long as you understand that this is absolutely wrong and grounds for being fired on the spot, here you go:
ViewBag.ProjectTimeSHeet = projectAssignment
.Concat(new[]
{
new ProjectTimesheetList
{
ProjectName = "Vacancy",
ProjectId = -1,
},
new ProjectTimesheetList
{
ProjectName = "Unplanned Absence",
ProjectId = -2,
},
new ProjectTimesheetList
{
ProjectName = "Planned Absence",
ProjectId = -3,
},
});
var myOptions = {
val1 : 'Vacancy',
val2 : 'Unplanned Absence',
val3 : 'Planned Absence',
};
var mySelect = $('#dropdownID');
$.each(myOptions, function(val, text) {
mySelect.append(
$('<option></option>').val(val).html(text)
);
});
through Javascript
var ddl = document.getElementById("dropdownID");
for ( let key in myOptions )
{
var option = document.createElement("OPTION");
option.innerHTML = key
option.value = myOptions[key]
ddl.options.add(option);
}
I have this code,
def delivery_date(request):
today = datetime.today().date()
results = [get(today)]
stages = Stage.objects.prefetch_related('Stage').all()
for i in range(3):
results.append(get(results[i]))
results = [{'date': i} for i in results]
stages = [{'menu': s} for s in stages]
for i in results:
for stage in stages:
stage['id'] = stage['menu'].id
stage['name'] = stage['menu'].name
stage['desc'] = stage['menu'].desc
stage['menu'] = stage['menu'].Stage.filter(
delivery_date__exact=i['date'])
stage['menu'] = serializers.serialize('python', stage['menu'])
i['menu'] = stages
i['date'] = i['date'].strftime('%b %-d')
return JsonResponse(results, safe=False)
But the results says,
this image
But if the results has only one date, it works.
Like this,
def delivery_date(request):
today = datetime.today().date()
results = [get(today)]
stages = Stage.objects.prefetch_related('Stage').all()
# for i in range(3):
# results.append(get(results[i]))
results = [{'date': i} for i in results]
stages = [{'menu': s} for s in stages]
for i in results:
for stage in stages:
stage['id'] = stage['menu'].id
stage['name'] = stage['menu'].name
stage['desc'] = stage['menu'].desc
stage['menu'] = stage['menu'].Stage.filter(
delivery_date__exact=i['date'])
stage['menu'] = serializers.serialize('python', stage['menu'])
i['menu'] = stages
i['date'] = i['date'].strftime('%b %-d')
return JsonResponse(results, safe=False)
The results,
[
{
"date" : Oct 25,
"menu" : [
{
"menu" : [
{
"model" : backend.product,
"pk" : 13,
"fields" : {
"name" : Tasty Tempeh,
"desc" : Nasi, Ayam, Wortel, Buncis, Bawang Merah, Bawang Putih, Daun Salam, Serai, Minyak Wijen, Minyak Kelapa Sawit.,
"desc_detail" : ,
"delivery_date" : 2019-10-25,
"avatar" : ,
"stage" : 1
}
}
],
"id" : 1,
"name" : Porridge,
"desc" :
}
}
]
What's wrong with my logic? Can Anyone helps?
it is just you missed that menu is a Dict which has a list as value say temp
and that temp file has a dict at its 0 indexes:
use the following :
stage['menu'][0]['id']
In Odoo v10 this on_change method worked pretty well:
#api.onchange("partner_id")
def onchange_partner_id(self):
self.zapocet_line_pohledavky = False
self.zapocet_line_zavazky = False
account_move_line_obj = self.env['account.move.line']
val = {'value': {'zapocet_line_pohledavky': [], 'zapocet_line_zavazky': []}}
for statement in self:
if statement.partner_id:
domain = [('account_id.user_type_id.type', 'in', ('payable', 'receivable')), ('move_id.state', '=', 'posted'),
('partner_id.id', '=', statement.partner_id.id),]
line_ids = account_move_line_obj.search(domain, order="date asc")
for line in line_ids:
if line.amount_residual != 0 and line.credit > 0:
res = {
"move_line_id": line.id,
}
val['value']['zapocet_line_zavazky'].append(res)
if line.amount_residual != 0 and line.debit > 0:
qes = {
"move_line_id": line.id,
}
val['value']['zapocet_line_pohledavky'].append(qes)
self.zapocet_line_pohledavky = val['value']['zapocet_line_pohledavky']
return val
Does anybody have a clue why in v11 it loads the lines well, but they disappear on saving?
I use PrestaShop 1.6.13. I user the Web Service of product which have id set 10 (http://myserver/api/products/10). When I update the attribute width, it displays an error:
Can you help me ??
I download the PSWebServiceLibrary.php file (URL: https://github.com/PrestaShop/PrestaShop-webservice-lib/blob/master/PSWebServiceLibrary.php). After that, I create a file PHp named product.php and I insert this code:
define('DEBUG', true);
ini_set('display_errors','on');
define('PS_SHOP_PATH', 'http://myserver/');
define('PS_WS_AUTH_KEY', 'key');
require_once('PSWebServiceLibrary.php');
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$xml = $webService->get(array('url' => PS_SHOP_PATH.'api/products?schema=synopsis'));
$opt = array('resource' => 'products');
$opt['id'] = 8;
$xml = $webService->get($opt);
$resources = $xml->children()->children();
$resources->quantity = 100;
$opt['putXml'] = $xml->asXML();
$xml = $webService->edit($opt);
I am trying to to do a real-time camera processing with OpenCV.
In the didOutputSampleBuffer-Method of AVCaptureVideoDataOutputSampleBufferDelegate I am creating a matrix out of a sampleBuffer (which works without any problems). But when performing certain methods, such as cv::GaussianBlur, the app crashes because of "exc_bad_access code=1, address = 0x10......". Do you know why?
cv::Mat matrix(bufferHeight, bufferWidth, CV_8UC4, baseAddress);
cv::GaussianBlur(matrix, matrix, cvSize(5,5), 0); // Crahes here
__ Edit:
Base Address is calculated as below (this is done in Swift in didOutputSampleBuffer-Method, before passing these variables to objective-c++)
var pixelBuffer: CVImageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer)!
CVPixelBufferLockBaseAddress(pixelBuffer, CVPixelBufferLockFlags(rawValue: 0))
var baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer)
____ Edit2:
Value of baseAddress:
0x0000000107790000
Value of pixelBuffer:
<CVPixelBuffer 0x17413aae0 width=1920 height=1080 pixelFormat=420v iosurface=0x1700039e0 planes=2>
<Plane 0 width=1920 height=1080 bytesPerRow=1920>
<Plane 1 width=960 height=540 bytesPerRow=1920>
<attributes=<CFBasicHash 0x17426e640 [0x1b8d18bb8]>{type = immutable dict, count = 5,
entries =>
0 : <CFString 0x1b300de28 [0x1b8d18bb8]>{contents = "PixelFormatDescription"} = <CFBasicHash 0x17426a080 [0x1b8d18bb8]>{type = immutable dict, count = 10,
entries =>
0 : <CFString 0x1b300e088 [0x1b8d18bb8]>{contents = "Planes"} = (
{
BitsPerBlock = 8;
BlackBlock = <10>;
FillExtendedPixelsCallback = <00000000 00000000 b840aa95 01000000 00000000 00000000>;
},
{
BitsPerBlock = 16;
BlackBlock = <8080>;
FillExtendedPixelsCallback = <00000000 00000000 443faa95 01000000 00000000 00000000>;
HorizontalSubsampling = 2;
VerticalSubsampling = 2;
}
)
2 : <CFString 0x1b300dd68 [0x1b8d18bb8]>{contents = "IOSurfaceOpenGLESFBOCompatibility"} = <CFBoolean 0x1b8d19110 [0x1b8d18bb8]>{value = true}
3 : <CFString 0x1b300e228 [0x1b8d18bb8]>{contents = "ContainsYCbCr"} = <CFBoolean 0x1b8d19110 [0x1b8d18bb8]>{value = true}
4 : <CFString 0x1b300dd48 [0x1b8d18bb8]>{contents = "IOSurfaceOpenGLESTextureCompatibility"} = <CFBoolean 0x1b8d19110 [0x1b8d18bb8]>{value = true}
5 : <CFString 0x1b300e288 [0x1b8d18bb8]>{contents = "ComponentRange"} = <CFString 0x1b300e2a8 [0x1b8d18bb8]>{contents = "VideoRange"}
6 : <CFString 0x1b300e008 [0x1b8d18bb8]>{contents = "PixelFormat"} = <CFNumber 0xb000000343230762 [0x1b8d18bb8]>{value = +875704438, type = kCFNumberSInt32Type}
7 : <CFString 0x1b300dd28 [0x1b8d18bb8]>{contents = "IOSurfaceCoreAnimationCompatibility"} = <CFBoolean 0x1b8d19110 [0x1b8d18bb8]>{value = true}
9 : <CFString 0x1b300e068 [0x1b8d18bb8]>{contents = "ContainsAlpha"} = <CFBoolean 0x1b8d19120 [0x1b8d18bb8]>{value = false}
10 : <CFString 0x1b300e248 [0x1b8d18bb8]>{contents = "ContainsRGB"} = <CFBoolean 0x1b8d19120 [0x1b8d18bb8]>{value = false}
11 : <CFString 0x1b300dd88 [0x1b8d18bb8]>{contents = "OpenGLESCompatibility"} = <CFBoolean 0x1b8d19110 [0x1b8d18bb8]>{value = true}
}
2 : <CFString 0x1b300dbe8 [0x1b8d18bb8]>{contents = "ExtendedPixelsRight"} = <CFNumber 0xb000000000000002 [0x1b8d18bb8]>{value = +0, type = kCFNumberSInt32Type}
3 : <CFString 0x1b300dbc8 [0x1b8d18bb8]>{contents = "ExtendedPixelsTop"} = <CFNumber 0xb000000000000002 [0x1b8d18bb8]>{value = +0, type = kCFNumberSInt32Type}
4 : <CFString 0x1b300dba8 [0x1b8d18bb8]>{contents = "ExtendedPixelsLeft"} = <CFNumber 0xb000000000000002 [0x1b8d18bb8]>{value = +0, type = kCFNumberSInt32Type}
5 : <CFString 0x1b300dc08 [0x1b8d18bb8]>{contents = "ExtendedPixelsBottom"} = <CFNumber 0xb000000000000082 [0x1b8d18bb8]>{value = +8, type = kCFNumberSInt32Type}
}
propagatedAttachments=<CFBasicHash 0x17426e900 [0x1b8d18bb8]>{type = mutable dict, count = 4,
entries =>
0 : <CFString 0x1b300d7c8 [0x1b8d18bb8]>{contents = "CVImageBufferYCbCrMatrix"} = <CFString 0x1b300d7e8 [0x1b8d18bb8]>{contents = "ITU_R_709_2"}
1 : <CFString 0x1b300d928 [0x1b8d18bb8]>{contents = "CVImageBufferTransferFunction"} = <CFString 0x1b300d7e8 [0x1b8d18bb8]>{contents = "ITU_R_709_2"}
2 : <CFString 0x1b3044fa0 [0x1b8d18bb8]>{contents = "MetadataDictionary"} = <CFBasicHash 0x170077840 [0x1b8d18bb8]>{type = mutable dict, count = 3,
entries =>
0 : <CFString 0x1b304d100 [0x1b8d18bb8]>{contents = "SNR"} = <CFNumber 0x170036300 [0x1b8d18bb8]>{value = +28.30700356903138370512, type = kCFNumberFloat64Type}
1 : <CFString 0x1b304b2e0 [0x1b8d18bb8]>{contents = "ExposureTime"} = <CFNumber 0x170033d00 [0x1b8d18bb8]>{value = +0.01000000000000000021, type = kCFNumberFloat64Type}
2 : <CFString 0x1b304d0e0 [0x1b8d18bb8]>{contents = "SensorID"} = <CFNumber 0xb000000000002472 [0x1b8d18bb8]>{value = +583, type = kCFNumberSInt32Type}
}
5 : <CFString 0x1b300d8a8 [0x1b8d18bb8]>{contents = "CVImageBufferColorPrimaries"} = <CFString 0x1b300d7e8 [0x1b8d18bb8]>{contents = "ITU_R_709_2"}
}
nonPropagatedAttachments=<CFBasicHash 0x17426e8c0 [0x1b8d18bb8]>{type = mutable dict, count = 0,
entries =>
}
Ah - your video data is not 4 component RGBA (or whatever), but "1.5" component YUV. You should either perform the blur in YUV, or perhaps more easily, switch your capture session to RGBA.
YUV is the default format & you've got two "planes" in it.
Plane 0 is "Y", a 1920x1080 8-bit bitmap, and plane 1 is "UV", a 960x540 16-bit bitmap (actually two 960x540 8-bit bitmaps side by side, U & V, not sure why they're not split into 3 planes really).
In any case, your code is expecting a 1920x1080 32-bit bitmap, and runs off the end of the Y channel's memory.
If you want to switch to RGBA, do (I think - I can never remember which 4 component format iOS uses):
output.videoSettings = [kCVPixelBufferPixelFormatTypeKey as AnyHashable: kCVPixelFormatType_32BGRA]
If you're feeling adventurous, do the blur on the yuv data - it's 2.666666667 times smaller, and your code could be 2.666667 times faster.