Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从ios应用程序在打开的图表中发布意外结果。除了照片以外的所有参数都不会显示在facebook上,但它可以在Graph API explorer中使用_Ios_Facebook Opengraph - Fatal编程技术网

从ios应用程序在打开的图表中发布意外结果。除了照片以外的所有参数都不会显示在facebook上,但它可以在Graph API explorer中使用

从ios应用程序在打开的图表中发布意外结果。除了照片以外的所有参数都不会显示在facebook上,但它可以在Graph API explorer中使用,ios,facebook-opengraph,Ios,Facebook Opengraph,我从字面上理解了“5-发布开放图故事”教程,但我面临一些问题。当我使用Graph API Explorer时,代码不会生成错误或警告,它会正确地显示在我的时间线中。请按照链接查看快照()。但当我的应用程序生成相同类型的代码并发布到打开的图形时,只上传照片,而不上传对象或动作。 () 代码如下: - (IBAction)publicar:(UIButton *)sender { if ([FBSession.activeSession.permissions indexOfOb

我从字面上理解了“5-发布开放图故事”教程,但我面临一些问题。当我使用Graph API Explorer时,代码不会生成错误或警告,它会正确地显示在我的时间线中。请按照链接查看快照()。但当我的应用程序生成相同类型的代码并发布到打开的图形时,只上传照片,而不上传对象或动作。 ()

代码如下:

- (IBAction)publicar:(UIButton *)sender {

    if ([FBSession.activeSession.permissions
     indexOfObject:@"publish_actions"] == NSNotFound) {

    [FBSession.activeSession
     reauthorizeWithPublishPermissions:[NSArray arrayWithObject:@"publish_actions"]
     defaultAudience:FBSessionDefaultAudienceFriends
     completionHandler:^(FBSession *session, NSError *error) {
         if (!error) {
             // re-call assuming we now have the permission
             [self publicar:sender];
         }
     }];
    } else {
    if (self.selectedPhoto) {
        [self postPhotoThenOpenGraphAction];
    } else {
        [self postOpenGraphActionWithPhotoURL:nil];
    }
   }

}

#pragma mark - SCOGProblema and SCOGDenunciarProblema protocols

- (id<SCOGProblema>)problemaObjectForMeal:(NSString*)problema
{
    // This URL is specific to this sample, and can be used to
    // create arbitrary OG objects for this app; your OG objects
    // will have URLs hosted by your server.
    NSString *format =
    @"https://boiling-spire-2233.herokuapp.com/index.php?"
    @"fb:app_id=412805615466140&og:type=%@&"
    @"og:title=%@&og:description=%%22%@%%22&"
    @"og:image=https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png&"
    @"body=%@";

    // We create an FBGraphObject object, but we can treat it as
    // an SCOGMeal with typed properties, etc. See <FacebookSDK/FBGraphObject.h>
    // for more details.
    id<SCOGProblema> result = (id<SCOGProblema>)[FBGraphObject graphObject];

    // Give it a URL that will echo back the name of the meal as its title,
    // description, and body.
    result.url = [NSString stringWithFormat:format,
                  @"orgdrsolutionpery:problema", problema, problema, problema];

    return result;
}


-(void) postOpenGraphActionWithPhotoURL:(NSString *)photoURL
{
    // First create the Open Graph meal object for the meal we ate.
    id<SCOGProblema> problemaObject = [self problemaObjectForMeal:self.problema];
    NSLog(@"%@",problemaObject);

    // Now create an Open Graph eat action with the meal, our location,
    // and the people we were with.
    id<SCOGDenunciarProblemaAction> action =
    (id<SCOGDenunciarProblemaAction>)[FBGraphObject graphObject];
    action.problema = problemaObject;
    if (self.selectedPlace) {
        action.place = self.selectedPlace;
    }

    if (photoURL) {
        NSMutableDictionary *image = [[NSMutableDictionary alloc] init];
        [image setObject:photoURL forKey:@"url"];

        NSMutableArray *images = [[NSMutableArray alloc] init];
        [images addObject:image];

        action.image = images;
    }

    // Create the request and post the action to the
    // "me/<YOUR_APP_NAMESPACE>:eat" path.
    [FBRequestConnection startForPostWithGraphPath:@"me/orgdrsolutionpery:denuncia"
                                   graphObject:action
                             completionHandler:
     ^(FBRequestConnection *connection, id result, NSError *error) {
         NSString *alertText;
         if (!error) {
             alertText = [NSString stringWithFormat:
                      @"Posted Open Graph action, id: %@",
                      [result objectForKey:@"id"]];
         } else {
            alertText = [NSString stringWithFormat:
                      @"error: domain = %@, code = %d",
                      error.domain, error.code];
     }
     [[[UIAlertView alloc] initWithTitle:@"Result"
                                 message:alertText
                                delegate:nil
                       cancelButtonTitle:@"Thanks!"
                       otherButtonTitles:nil]
      show];
 }
 ];

}

- (void)postPhotoThenOpenGraphAction
{
    [FBSettings setLoggingBehavior:[NSSet
                                setWithObjects:FBLoggingBehaviorFBRequests,
                                FBLoggingBehaviorFBURLConnections,
                                nil]];

    FBRequestConnection *connection = [[FBRequestConnection alloc] init];

    // First request uploads the photo.
    FBRequest *request1 = [FBRequest
                       requestForUploadPhoto:self.selectedPhoto];
        [connection addRequest:request1
         completionHandler:
     ^(FBRequestConnection *connection, id result, NSError *error) {
         if (!error) {
         }
     }
            batchEntryName:@"photopost"
     ];


    // Second request retrieves photo information for just-created
    // photo so we can grab its source.
    FBRequest *request2 = [FBRequest
                       requestForGraphPath:@"{result=photopost:$.id}"];
    [connection addRequest:request2
     completionHandler:
     ^(FBRequestConnection *connection, id result, NSError *error) {
         if (!error &&
             result) {
             NSString *source = [result objectForKey:@"source"];
             [self postOpenGraphActionWithPhotoURL:source];
         }
     }
     ];

    [connection start];
-(iAction)publicar:(UIButton*)发送方{
如果([FBSession.activeSession.permissions
IndexOfoObject:@“发布操作”]==NSNotFound){
[FBSession.activeSession]
重新授权WithPublishPermissions:[NSArray arrayWithObject:@“发布操作”]
默认观众:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession*会话,NSError*错误){
如果(!错误){
//如果我们现在得到许可,请重新致电
[自公布者:发送者];
}
}];
}否则{
如果(自选照片){
[自身后摄片作用];
}否则{
[self-postOpenGraphActionWithPhotoURL:nil];
}
}
}
#pragma-mark-SCOGProblema和scogdensiarproblema协议
-(id)问题对象形式:(NSString*)问题
{
//此URL特定于此示例,可用于
//为此应用创建任意OG对象;您的OG对象
//将由您的服务器托管URL。
NSString*格式=
@"https://boiling-spire-2233.herokuapp.com/index.php?"
@“fb:app_id=412805615466140&og:type=%@&”
@“og:title=%@&og:description=%%22%@%%22&”
@“og:图像=https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png&"
@“正文=%@”;
//我们创建一个FBGraphObject对象,但我们可以将其视为
//具有类型化属性等的SCOGMeal。请参阅
//更多细节。
id结果=(id)[FBGraphObject graphObject];
//给它一个URL,它会回显食物的名称作为它的标题,
//描述,和正文。
result.url=[NSString stringWithFormat:format,
@“组织解决方案:问题”,问题,问题,问题];
返回结果;
}
-(void)postOpenGraphActionWithPhotoURL:(NSString*)photoURL
{
//首先,为我们所吃的食物创建opengraph餐对象。
id problemaObject=[self problemaObjectForMeal:self.problema];
NSLog(@“%@”,问题对象);
//现在创建一个开放的图形eat action,其中包含用餐、我们的位置、,
//和我们在一起的人。
id动作=
(id)[FBGraphObject-graphObject];
action.problema=problemaObject;
如果(自行选择的地点){
action.place=self.selectedPlace;
}
如果(照片URL){
NSMutableDictionary*image=[[NSMutableDictionary alloc]init];
[图像集对象:photoURL forKey:@“url”];
NSMutableArray*图像=[[NSMutableArray alloc]init];
[图像添加对象:图像];
action.image=图像;
}
//创建请求并将操作发布到
//“我/:吃”路径。
[FBRequestConnection startForPostWithGraphPath:@“me/orgdrsolutionpery:Denancia”
graphObject:动作
completionHandler:
^(FBRequestConnection*连接,id结果,N错误*错误){
NSString*警报文本;
如果(!错误){
alertText=[NSString stringWithFormat:
@“已发布打开图形操作,id:%@”,
[结果objectForKey:@“id”];
}否则{
alertText=[NSString stringWithFormat:
@“错误:域=%@,代码=%d”,
error.domain,error.code];
}
[[[UIAlertView alloc]initWithTitle:@“结果”
信息:alertText
代表:无
取消按钮:@“谢谢!”
其他按钮:无]
显示];
}
];
}
-(无效)摄影后子宫内膜异位症
{
[FBSettings setLoggingBehavior:[NSSet
setWithObjects:FBLoggingBehavior FBRequests,
FBLoggingBehaviorFBURLConnections,
无]];
FBRequestConnection*连接=[[FBRequestConnection alloc]init];
//第一个请求上传照片。
FBRequest*request1=[FBRequest
上传照片请求:self.selectedPhoto];
[连接添加请求:请求1
completionHandler:
^(FBRequestConnection*连接,id结果,N错误*错误){
如果(!错误){
}
}
batchEntryName:@“photopost”
];
//第二个请求检索刚创建的对象的照片信息
//所以我们可以抓住它的来源。
FBRequest*request2=[FBRequest
requestForGraphPath:@“{result=photopost:$.id}”;
[连接添加请求:请求2
completionHandler:
^(FBRequestConnection*连接,id结果,N错误*错误){
如果(!错误&&
结果){
NSString*source=[result objectForKey:@“source”];
[self-postOpenGraphActionWithPhotoURL:source];
}
}
];
[连接启动];